-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3eaef9a
commit 9fe5c0c
Showing
22 changed files
with
1,544 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
MapKitAndCoreLocation.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
MapKitAndCoreLocation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+47.9 KB
...roject.xcworkspace/xcuserdata/jijo.pulikkottil.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
...on.xcodeproj/xcuserdata/jijo.pulikkottil.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
uuid = "5B71ECA6-58CD-4010-B46C-C6A691703ED7" | ||
type = "1" | ||
version = "2.0"> | ||
</Bucket> |
14 changes: 14 additions & 0 deletions
14
...tion.xcodeproj/xcuserdata/jijo.pulikkottil.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>MapKitAndCoreLocation.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
80 changes: 80 additions & 0 deletions
80
MapKitAndCoreLocation/Annotations/AnnotationViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// AnnotationViewController.swift | ||
// MapIntro | ||
// | ||
// Created by Jijo Pulikkottil on 09/09/20. | ||
// Copyright © 2020 mVoc. All rights reserved. | ||
// | ||
//https://developer.apple.com/documentation/mapkit/mkannotationview/decluttering_a_map_with_mapkit_annotation_clustering | ||
import UIKit | ||
import MapKit | ||
|
||
struct MyLocation { | ||
var locationName: String | ||
var locationCoordinate: CLLocationCoordinate2D | ||
} | ||
|
||
class AnnotationViewController: UIViewController { | ||
|
||
//10.0443° N, 76.3282° E | ||
let annotationViewItentifier = "MyAnnotationView" | ||
@IBOutlet weak var mapView: MKMapView! | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
// Do any additional setup after loading the view. | ||
//mapView.mapType = .satellite | ||
mapView.delegate = self | ||
|
||
//registering our custom class as annotation view. So no need to explicitly create instance of MyAnnotationView | ||
// mapView.register(MyAnnotationView.self, forAnnotationViewWithReuseIdentifier: MKMapViewDefaultAnnotationViewReuseIdentifier) | ||
// mapView.register(MyClusterAnnotationView.self, forAnnotationViewWithReuseIdentifier: MKMapViewDefaultClusterAnnotationViewReuseIdentifier) | ||
|
||
let c1 = CLLocationCoordinate2D(latitude: 10.0243, longitude: 76.3282) | ||
let c2 = CLLocationCoordinate2D(latitude: 10.0343, longitude: 76.3382) | ||
let c3 = CLLocationCoordinate2D(latitude: 10.0443, longitude: 76.3282) | ||
|
||
|
||
let l1 = MyLocation(locationName: "A1", locationCoordinate: c1) | ||
let l2 = MyLocation(locationName: "A2", locationCoordinate: c2) | ||
let l3 = MyLocation(locationName: "A3", locationCoordinate: c3) | ||
|
||
|
||
let arrayAnnotation = [l1, l2, l3].map { MyAnnotation($0) } | ||
mapView.addAnnotations(arrayAnnotation) | ||
|
||
mapView.showAnnotations(arrayAnnotation, animated: true) | ||
|
||
// let span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1) | ||
// mapView.setRegion(MKCoordinateRegion(center: c1, span: span), animated: true) | ||
// | ||
} | ||
} | ||
|
||
extension AnnotationViewController: MKMapViewDelegate { | ||
|
||
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { | ||
if let myAnnotation = annotation as? MyAnnotation { | ||
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationViewItentifier) | ||
if annotationView == nil { | ||
annotationView = MyAnnotationView(annotation: myAnnotation, reuseIdentifier: annotationViewItentifier) | ||
} | ||
return annotationView | ||
} else if let clusterAnnotation = annotation as? MKClusterAnnotation { | ||
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "MyClusterAnnotationView") | ||
if annotationView == nil { | ||
annotationView = MyClusterAnnotationView(annotation: clusterAnnotation, reuseIdentifier: "MyClusterAnnotationView") | ||
} | ||
return annotationView | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
|
||
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { | ||
|
||
if let annotateView = view as? MyAnnotationView { | ||
print("location = \(annotateView.location)") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Anntotion.swift | ||
// MapIntro | ||
// | ||
// Created by Jijo Pulikkottil on 13/09/20. | ||
// Copyright © 2020 mVoc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MapKit | ||
|
||
class MyAnnotation: MKPointAnnotation { | ||
|
||
var location: MyLocation? | ||
init(_ location: MyLocation) { | ||
super.init() | ||
self.location = location | ||
self.title = location.locationName | ||
self.coordinate = location.locationCoordinate | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// MyAnnotation.swift | ||
// MapIntro | ||
// | ||
// Created by Jijo Pulikkottil on 13/09/20. | ||
// Copyright © 2020 mVoc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MapKit | ||
|
||
class MyAnnotationView: MKMarkerAnnotationView { | ||
|
||
var location: String? | ||
override var annotation: MKAnnotation? { | ||
willSet { | ||
clusteringIdentifier = "JIJO" | ||
if let anno = newValue as? MyAnnotation { | ||
location = anno.location?.locationName | ||
//glyphText = anno.displayName | ||
markerTintColor = UIColor.green | ||
canShowCallout = true | ||
let button = UIButton(type: UIButton.ButtonType.detailDisclosure) | ||
rightCalloutAccessoryView = button | ||
displayPriority = .defaultHigh | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
MapKitAndCoreLocation/Annotations/MyClusterAnnotationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// MyClusterAnnotationView.swift | ||
// MapIntro | ||
// | ||
// Created by Jijo Pulikkottil on 15/09/20. | ||
// Copyright © 2020 mVoc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MapKit | ||
|
||
class MyClusterAnnotationView: MKMarkerAnnotationView { | ||
|
||
|
||
override var annotation: MKAnnotation? { | ||
willSet { | ||
if let cluster = newValue as? MKClusterAnnotation { | ||
glyphText = "C"//\(cluster.memberAnnotations.count)" | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// AppDelegate.swift | ||
// MapKitAndCoreLocation | ||
// | ||
// Created by Jijo Pulikkottil on 16/09/20. | ||
// Copyright © 2020 MVoc. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
@UIApplicationMain | ||
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
|
||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
// Override point for customization after application launch. | ||
return true | ||
} | ||
|
||
// MARK: UISceneSession Lifecycle | ||
|
||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { | ||
// Called when a new scene session is being created. | ||
// Use this method to select a configuration to create the new scene with. | ||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) | ||
} | ||
|
||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { | ||
// Called when the user discards a scene session. | ||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. | ||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return. | ||
} | ||
|
||
|
||
} | ||
|
98 changes: 98 additions & 0 deletions
98
MapKitAndCoreLocation/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "2x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"scale" : "3x", | ||
"size" : "60x60" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "20x20" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "29x29" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "40x40" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "1x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "76x76" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"scale" : "2x", | ||
"size" : "83.5x83.5" | ||
}, | ||
{ | ||
"idiom" : "ios-marketing", | ||
"scale" : "1x", | ||
"size" : "1024x1024" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<scene sceneID="EHf-IW-A2E"> | ||
<objects> | ||
<viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
</view> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="53" y="375"/> | ||
</scene> | ||
</scenes> | ||
</document> |
Oops, something went wrong.