From fc82d09a0d1bdd7ca15baa2eb0c78e3cd8d02e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Pawo=C5=82ka?= Date: Fri, 22 May 2026 11:10:19 +0200 Subject: [PATCH 1/3] Fix Android annotation layer ordering --- src/ui-mapbox/index.android.ts | 6 +++--- src/ui-mapbox/markers/MarkerManager.android.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui-mapbox/index.android.ts b/src/ui-mapbox/index.android.ts index ea8a278..86f55fb 100755 --- a/src/ui-mapbox/index.android.ts +++ b/src/ui-mapbox/index.android.ts @@ -669,7 +669,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi { const annotationPlugin = this._getPlugin('MAPBOX_ANNOTATION_PLUGIN_ID'); this.lineManager = annotationPlugin.createAnnotationManager( com.mapbox.maps.plugin.annotation.AnnotationType.PolylineAnnotation, - new com.mapbox.maps.plugin.annotation.AnnotationConfig() + new com.mapbox.maps.plugin.annotation.AnnotationConfig(MarkerManager.LAYER_ID) ) as com.mapbox.maps.plugin.annotation.generated.PolylineAnnotationManager; this.onAnnotationClickListener = new com.mapbox.maps.plugin.annotation.generated.OnPolylineAnnotationClickListener({ @@ -1754,7 +1754,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi { const annotationPlugin = this._getPlugin('MAPBOX_ANNOTATION_PLUGIN_ID'); this.polygonManager = annotationPlugin.createAnnotationManager( com.mapbox.maps.plugin.annotation.AnnotationType.PolygonAnnotation, - new com.mapbox.maps.plugin.annotation.AnnotationConfig() + new com.mapbox.maps.plugin.annotation.AnnotationConfig(MarkerManager.LAYER_ID) ) as com.mapbox.maps.plugin.annotation.generated.PolygonAnnotationManager; } const polygonOptions = new com.mapbox.maps.plugin.annotation.generated.PolygonAnnotationOptions(); @@ -1796,7 +1796,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi { const annotationPlugin = this._getPlugin('MAPBOX_ANNOTATION_PLUGIN_ID'); this.lineManager = annotationPlugin.createAnnotationManager( com.mapbox.maps.plugin.annotation.AnnotationType.PolylineAnnotation, - new com.mapbox.maps.plugin.annotation.AnnotationConfig() + new com.mapbox.maps.plugin.annotation.AnnotationConfig(MarkerManager.LAYER_ID) ) as com.mapbox.maps.plugin.annotation.generated.PolylineAnnotationManager; } const polylineOptions = new com.mapbox.maps.plugin.annotation.generated.PolylineAnnotationOptions(); diff --git a/src/ui-mapbox/markers/MarkerManager.android.ts b/src/ui-mapbox/markers/MarkerManager.android.ts index b2cbd73..8e554f8 100644 --- a/src/ui-mapbox/markers/MarkerManager.android.ts +++ b/src/ui-mapbox/markers/MarkerManager.android.ts @@ -29,7 +29,7 @@ export class MarkerManager { this.mapView = mapView; this.onInfoWindowTapped = onInfoWindowClick; const AnnotationConfig = com.mapbox.maps.plugin.annotation.AnnotationConfig; - const layerConfig = new AnnotationConfig(MarkerManager.LAYER_ID); + const layerConfig = new AnnotationConfig(null, MarkerManager.LAYER_ID); const annotationPlugin = mapView.getPlugin('MAPBOX_ANNOTATION_PLUGIN_ID') as com.mapbox.maps.plugin.annotation.AnnotationPlugin; this.pointAnnotationManager = annotationPlugin.createAnnotationManager( com.mapbox.maps.plugin.annotation.AnnotationType.PointAnnotation, From 7fe34cc67b234e1fec886b92e4c4b95cb8073490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Pawo=C5=82ka?= Date: Fri, 22 May 2026 15:20:32 +0200 Subject: [PATCH 2/3] Fix iOS annotation layer ordering --- .../platforms/ios/src/MapboxBridge.swift | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift b/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift index 12f8892..382c30c 100644 --- a/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift +++ b/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift @@ -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", + 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", + 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) { From 0c4c72c5b1d692b34c11259caee0ba6fd7e7b212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Pawo=C5=82ka?= Date: Mon, 25 May 2026 08:50:35 +0200 Subject: [PATCH 3/3] refactor(ios): centralize point annotation manager init --- .../platforms/ios/src/MapboxBridge.swift | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift b/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift index 382c30c..9b32183 100644 --- a/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift +++ b/packages/ui-mapbox/platforms/ios/src/MapboxBridge.swift @@ -97,6 +97,9 @@ public class MapboxBridge: NSObject { } public static let MARKER_LAYER_ID = "mapbox-ios-markers" + public static let POLYLINE_LAYER_ID = "mapbox-ios-polylines" + public static let POLYGON_LAYER_ID = "mapbox-ios-polygons" + public static let POLYGON_OUTLINE_LAYER_ID = "mapbox-ios-polygon-outlines" // Notification constants public static let MapLoadedNotification = "MapboxBridgeMapLoaded" @@ -170,6 +173,16 @@ public class MapboxBridge: NSObject { return MapboxBridge.bridgeTable.object(forKey: mapView) as? MapboxBridge } + private func ensurePointAnnotationManager(for mapView: MapView) -> PointAnnotationManager { + if let manager = pointAnnotationManager { + return manager + } + + let manager = mapView.annotations.makePointAnnotationManager(id: MapboxBridge.MARKER_LAYER_ID) + pointAnnotationManager = manager + return manager + } + @objc public func getMapView() -> MapView? { return mapView } @@ -205,8 +218,7 @@ 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) + _ = ensurePointAnnotationManager(for: mv) let defaultPinImage = UIImage(named: "default_pin") if (defaultPinImage != nil) { self.defaultPinImageHeight = defaultPinImage!.size.height @@ -448,10 +460,7 @@ public class MapboxBridge: NSObject { guard let data = markersJSON.data(using: .utf8) else { return } guard let markers = try? JSONSerialization.jsonObject(with: data, options: []) as! [NSDictionary] else { return } - if pointAnnotationManager == nil { - pointAnnotationManager = mv.annotations.makePointAnnotationManager(id: MapboxBridge.MARKER_LAYER_ID) - } - guard let manager = pointAnnotationManager else { return } + let manager = ensurePointAnnotationManager(for: mv) var current = manager.annotations var additions: [PointAnnotation] = [] @@ -938,9 +947,10 @@ public class MapboxBridge: NSObject { } + _ = ensurePointAnnotationManager(for: mv) if polylineAnnotationManager == nil { polylineAnnotationManager = mv.annotations.makePolylineAnnotationManager( - id: "mapbox-ios-polylines", + id: MapboxBridge.POLYLINE_LAYER_ID, layerPosition: .below(MapboxBridge.MARKER_LAYER_ID) ) } @@ -1145,9 +1155,10 @@ public class MapboxBridge: NSObject { } + _ = ensurePointAnnotationManager(for: mv) if polygonAnnotationManager == nil { polygonAnnotationManager = mv.annotations.makePolygonAnnotationManager( - id: "mapbox-ios-polygons", + id: MapboxBridge.POLYGON_LAYER_ID, layerPosition: .below(MapboxBridge.MARKER_LAYER_ID) ) } @@ -1173,7 +1184,7 @@ public class MapboxBridge: NSObject { if (strokeOpacity != nil || strokeWidth != nil){ if polygonOutlineAnnotationManager == nil { polygonOutlineAnnotationManager = mv.annotations.makePolylineAnnotationManager( - id: "mapbox-ios-polygon-outlines", + id: MapboxBridge.POLYGON_OUTLINE_LAYER_ID, layerPosition: .below(MapboxBridge.MARKER_LAYER_ID) ) }