-
Notifications
You must be signed in to change notification settings - Fork 26
Fix Android/IOS annotation layer ordering for markers, polylines and polygons #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,8 @@ public class MapboxBridge: NSObject { | |
| public func postEvent(_ event: String) { | ||
| NotificationCenter.default.post(name: Notification.Name(event), object: self.mapView) | ||
| } | ||
|
|
||
| public static let MARKER_LAYER_ID = "mapbox-ios-markers" | ||
|
|
||
| // Notification constants | ||
| public static let MapLoadedNotification = "MapboxBridgeMapLoaded" | ||
|
|
@@ -203,6 +205,8 @@ public class MapboxBridge: NSObject { | |
|
|
||
| // Register this bridge for the created MapView | ||
| MapboxBridge.registerBridge(self, for: mv) | ||
|
|
||
| pointAnnotationManager = mv.annotations.makePointAnnotationManager(id: MapboxBridge.MARKER_LAYER_ID) | ||
| let defaultPinImage = UIImage(named: "default_pin") | ||
| if (defaultPinImage != nil) { | ||
| self.defaultPinImageHeight = defaultPinImage!.size.height | ||
|
|
@@ -445,7 +449,7 @@ public class MapboxBridge: NSObject { | |
| guard let markers = try? JSONSerialization.jsonObject(with: data, options: []) as! [NSDictionary] else { return } | ||
|
|
||
| if pointAnnotationManager == nil { | ||
| pointAnnotationManager = mv.annotations.makePointAnnotationManager() | ||
| pointAnnotationManager = mv.annotations.makePointAnnotationManager(id: MapboxBridge.MARKER_LAYER_ID) | ||
| } | ||
| guard let manager = pointAnnotationManager else { return } | ||
|
|
||
|
|
@@ -935,7 +939,10 @@ public class MapboxBridge: NSObject { | |
|
|
||
|
|
||
| if polylineAnnotationManager == nil { | ||
| polylineAnnotationManager = mv.annotations.makePolylineAnnotationManager() | ||
| polylineAnnotationManager = mv.annotations.makePolylineAnnotationManager( | ||
| id: "mapbox-ios-polylines", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use a static property for the name here too, as you use it in multiple places ? |
||
| layerPosition: .below(MapboxBridge.MARKER_LAYER_ID) | ||
| ) | ||
| } | ||
| guard let manager = polylineAnnotationManager else { return false } | ||
| var annotation = PolylineAnnotation(id: id, lineCoordinates: ccoords) | ||
|
|
@@ -1139,7 +1146,10 @@ public class MapboxBridge: NSObject { | |
|
|
||
|
|
||
| if polygonAnnotationManager == nil { | ||
| polygonAnnotationManager = mv.annotations.makePolygonAnnotationManager() | ||
| polygonAnnotationManager = mv.annotations.makePolygonAnnotationManager( | ||
| id: "mapbox-ios-polygons", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use a static property for the name here too, as you use it in multiple places ? |
||
| layerPosition: .below(MapboxBridge.MARKER_LAYER_ID) | ||
| ) | ||
| } | ||
| guard let manager = polygonAnnotationManager else { return false } | ||
| let polygon = Polygon(outerRing: .init(coordinates: ccoords)) | ||
|
|
@@ -1162,7 +1172,10 @@ public class MapboxBridge: NSObject { | |
|
|
||
| if (strokeOpacity != nil || strokeWidth != nil){ | ||
| if polygonOutlineAnnotationManager == nil { | ||
| polygonOutlineAnnotationManager = mv.annotations.makePolylineAnnotationManager() | ||
| polygonOutlineAnnotationManager = mv.annotations.makePolylineAnnotationManager( | ||
| id: "mapbox-ios-polygon-outlines", | ||
| layerPosition: .below(MapboxBridge.MARKER_LAYER_ID) | ||
| ) | ||
| } | ||
| var outline = PolylineAnnotation(id: id, lineCoordinates: ccoords) | ||
| if (strokeColor != nil) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you instantiate here when you are already doing it later when accessed?