-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix file paths, remove unused storybaord vc Address feedback Fix file name whyyy
- Loading branch information
1 parent
6d7e44e
commit 9edcb29
Showing
33 changed files
with
1,435 additions
and
154 deletions.
There are no files selected for viewing
118 changes: 112 additions & 6 deletions
118
annotations-framework-extension/MapboxAnnotationsExtension.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...ramework-extension/annotationapp/Assets.xcassets/camera-icon-image.imageset/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,24 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "camera-icon-image.pdf", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+4.38 KB
...-extension/annotationapp/Assets.xcassets/camera-icon-image.imageset/camera-icon-image.pdf
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
annotations-framework-extension/annotationapp/Assets.xcassets/dots.imageset/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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "dots.pdf", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+4.04 KB
annotations-framework-extension/annotationapp/Assets.xcassets/dots.imageset/dots.pdf
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
...-framework-extension/annotationapp/Assets.xcassets/flag-icon-image.imageset/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,24 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "flag-icon-image.pdf", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+4.09 KB
...work-extension/annotationapp/Assets.xcassets/flag-icon-image.imageset/flag-icon-image.pdf
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
annotations-framework-extension/annotationapp/Assets.xcassets/squares.imageset/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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "squares.pdf", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+4.09 KB
annotations-framework-extension/annotationapp/Assets.xcassets/squares.imageset/squares.pdf
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
...-framework-extension/annotationapp/Assets.xcassets/star-icon-image.imageset/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,24 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "star-icon-image.pdf", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+3.85 KB
...work-extension/annotationapp/Assets.xcassets/star-icon-image.imageset/star-icon-image.pdf
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
annotations-framework-extension/annotationapp/Assets.xcassets/stars.imageset/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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "stars.pdf", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+3.87 KB
annotations-framework-extension/annotationapp/Assets.xcassets/stars.imageset/stars.pdf
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
annotations-framework-extension/annotationapp/Assets.xcassets/stripes.imageset/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,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "stripes.pdf", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Binary file added
BIN
+3.89 KB
annotations-framework-extension/annotationapp/Assets.xcassets/stripes.imageset/stripes.pdf
Binary file not shown.
14 changes: 9 additions & 5 deletions
14
annotations-framework-extension/annotationapp/Base.lproj/Main.storyboard
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
175 changes: 175 additions & 0 deletions
175
annotations-framework-extension/annotationapp/Controllers/MapViewController.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,175 @@ | ||
import UIKit | ||
import Mapbox | ||
import MapboxAnnotationsExtension | ||
|
||
class MapViewController: UIViewController { | ||
|
||
var mapView: MGLMapView! | ||
|
||
var circleAnnotationController: MGLCircleAnnotationController! | ||
var circleAnnotation: MGLCircleStyleAnnotation! | ||
|
||
var symbolAnnotationController: MGLSymbolAnnotationController! | ||
var symbolAnnotation: MGLSymbolStyleAnnotation! | ||
|
||
var lineAnnotationController: MGLLineAnnotationController! | ||
var lineAnnotation: MGLLineStyleAnnotation! | ||
|
||
var polygonAnnotationController: MGLPolygonAnnotationController! | ||
var polygonAnnotation: MGLPolygonStyleAnnotation! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
mapView = MGLMapView(frame: view.bounds, styleURL: MGLStyle.streetsStyleURL) | ||
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | ||
mapView.setCenter(CLLocationCoordinate2D(latitude: -42, longitude: -187.5), zoomLevel: 4, animated: false) | ||
mapView.delegate = self | ||
view.addSubview(mapView) | ||
|
||
let singleTap = UITapGestureRecognizer(target: self, action: #selector(handleMapTap(sender:))) | ||
mapView.addGestureRecognizer(singleTap) | ||
} | ||
|
||
@objc func handleMapTap(sender: UITapGestureRecognizer) { | ||
let coordinate = mapView.convert(sender.location(in: mapView), toCoordinateFrom: mapView) | ||
print(coordinate) | ||
} | ||
|
||
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) { | ||
self.loadStyleImages(for: style) | ||
self.addCircleStyleAnnotation() | ||
self.addSymbolStyleAnnotation() | ||
self.addLineStyleAnnotation() | ||
self.addPolygonStyleAnnotation() | ||
} | ||
|
||
// MARK: Style annotation setup | ||
|
||
func loadStyleImages(for style: MGLStyle) { | ||
style.setImage(UIImage(named: "star-icon-image")!, forName: "star-icon-image") | ||
style.setImage(UIImage(named: "camera-icon-image")!, forName: "camera-icon-image") | ||
style.setImage(UIImage(named: "flag-icon-image")!, forName: "flag-icon-image") | ||
|
||
style.setImage(UIImage(named: "squares")!, forName: "Squares") | ||
style.setImage(UIImage(named: "dots")!, forName: "Dots") | ||
style.setImage(UIImage(named: "stripes")!, forName: "Stripes") | ||
} | ||
|
||
func addCircleStyleAnnotation() { | ||
circleAnnotationController = MGLCircleAnnotationController(mapView: mapView) | ||
circleAnnotationController.delegate = self | ||
circleAnnotationController.annotationsInteractionEnabled = true | ||
let circleCoordinate = CLLocationCoordinate2D(latitude: -45, longitude: -183) | ||
circleAnnotation = MGLCircleStyleAnnotation(center: circleCoordinate) | ||
circleAnnotation.title = "circle" | ||
circleAnnotation.circleColor = UIColor.red | ||
circleAnnotation.circleRadius = 20.0 | ||
circleAnnotation.circleOpacity = 0.8 | ||
circleAnnotationController.addStyleAnnotation(circleAnnotation) | ||
} | ||
|
||
func addSymbolStyleAnnotation() { | ||
symbolAnnotationController = MGLSymbolAnnotationController(mapView: mapView) | ||
symbolAnnotationController.delegate = self | ||
symbolAnnotationController.annotationsInteractionEnabled = true | ||
let symbolCoordinate = CLLocationCoordinate2D(latitude: -34, longitude: -187) | ||
symbolAnnotation = MGLSymbolStyleAnnotation(coordinate: symbolCoordinate) | ||
symbolAnnotation.title = "symbol" | ||
symbolAnnotation.text = "Label" | ||
symbolAnnotation.textFontSize = 36.0 | ||
symbolAnnotation.iconImageName = "camera-icon-image" | ||
symbolAnnotation.textOffset = CGVector(dx: 0.0, dy: -1.0) | ||
|
||
symbolAnnotation.textHaloWidth = 2.0 | ||
symbolAnnotation.textHaloBlur = 2.0 | ||
symbolAnnotation.textHaloColor = UIColor.red | ||
|
||
symbolAnnotationController.addStyleAnnotation(symbolAnnotation) | ||
} | ||
|
||
func addLineStyleAnnotation() { | ||
|
||
let lineCoordinates = [ | ||
CLLocationCoordinate2D(latitude: -46.392, longitude: 168.303), | ||
CLLocationCoordinate2D(latitude: -45.047, longitude: 168.670), | ||
CLLocationCoordinate2D(latitude: -43.544, longitude: 172.631), | ||
CLLocationCoordinate2D(latitude: -41.273, longitude: 173.283), | ||
CLLocationCoordinate2D(latitude: -41.299, longitude: 174.779), | ||
CLLocationCoordinate2D(latitude: -36.877, longitude: 174.755) | ||
] | ||
|
||
lineAnnotationController = MGLLineAnnotationController(mapView: mapView) | ||
lineAnnotationController.delegate = self | ||
lineAnnotationController.annotationsInteractionEnabled = true | ||
lineAnnotation = MGLLineStyleAnnotation(coordinates: lineCoordinates, count: UInt(lineCoordinates.count)) | ||
lineAnnotation.title = "line" | ||
lineAnnotation.lineWidth = 5.0 | ||
lineAnnotation.lineColor = .blue | ||
lineAnnotationController.addStyleAnnotation(lineAnnotation) | ||
} | ||
|
||
func addPolygonStyleAnnotation() { | ||
|
||
let polygonCoordinates = [ | ||
CLLocationCoordinate2D(latitude: -40.21, longitude: 166.15), | ||
CLLocationCoordinate2D(latitude: -40.21, longitude: 171.07), | ||
CLLocationCoordinate2D(latitude: -36.17, longitude: 171.07), | ||
CLLocationCoordinate2D(latitude: -36.17, longitude: 166.15), | ||
CLLocationCoordinate2D(latitude: -40.21, longitude: 166.15) | ||
] | ||
|
||
polygonAnnotationController = MGLPolygonAnnotationController(mapView: mapView) | ||
polygonAnnotationController.delegate = self | ||
polygonAnnotationController.annotationsInteractionEnabled = true | ||
polygonAnnotation = MGLPolygonStyleAnnotation(coordinates: polygonCoordinates, count: UInt(polygonCoordinates.count)) | ||
polygonAnnotation.title = "polygon" | ||
polygonAnnotation.fillColor = UIColor.yellow.withAlphaComponent(0.4) | ||
polygonAnnotation.fillOutlineColor = .black | ||
polygonAnnotationController.addStyleAnnotation(polygonAnnotation) | ||
} | ||
} | ||
|
||
extension MapViewController: MGLMapViewDelegate { | ||
// This is required in order to hide the default Maps SDK pin | ||
func mapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? { | ||
return MGLAnnotationView(frame: CGRect(x: 0, y: 0, width: 10, height: 10)) | ||
} | ||
} | ||
|
||
extension MapViewController: MGLAnnotationControllerDelegate { | ||
func annotationController(_ annotationController: MGLAnnotationController, didSelect styleAnnotation: MGLStyleAnnotation) { | ||
let settingsViewController = SettingsViewController(for: styleAnnotation) | ||
settingsViewController.delegate = self | ||
let customTransitioningDelegate = PresentationControllerDelegate() | ||
settingsViewController.transitioningDelegate = customTransitioningDelegate | ||
settingsViewController.modalPresentationStyle = .custom | ||
self.present(settingsViewController, animated: true, completion: nil) | ||
} | ||
|
||
func annotationController(_ annotationController: MGLAnnotationController, didDeselect styleAnnotation: MGLStyleAnnotation) { | ||
// This isn't an optional method so we have to do something here. | ||
// Ref: https://github.com/mapbox/map-extensions-ios/issues/44 | ||
print("Deselected style annotation") | ||
} | ||
} | ||
|
||
extension MapViewController: AnnotationStyleSettingsDelegate { | ||
func didUpdateStyleAnnotation(with updatedAnnotation: MGLStyleAnnotation) { | ||
if updatedAnnotation is MGLCircleStyleAnnotation { | ||
circleAnnotationController.updateStyleAnnotation(updatedAnnotation) | ||
} | ||
|
||
if updatedAnnotation is MGLSymbolStyleAnnotation { | ||
symbolAnnotationController.updateStyleAnnotation(updatedAnnotation) | ||
} | ||
|
||
if updatedAnnotation is MGLLineStyleAnnotation { | ||
lineAnnotationController.updateStyleAnnotation(updatedAnnotation) | ||
} | ||
|
||
if updatedAnnotation is MGLPolygonStyleAnnotation { | ||
polygonAnnotationController.updateStyleAnnotation(updatedAnnotation) | ||
} | ||
} | ||
} |
Oops, something went wrong.