@rnmapbox/maps 10.1.31 → 10.1.32-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ import com.facebook.react.bridge.ReactApplicationContext
5
5
  import com.facebook.react.uimanager.ThemedReactContext
6
6
  import com.facebook.react.uimanager.annotations.ReactProp
7
7
  import com.facebook.react.viewmanagers.RNMBXRasterSourceManagerInterface
8
+ import com.rnmapbox.rnmbx.events.constants.EventKeys
9
+ import com.rnmapbox.rnmbx.events.constants.eventMapOf
8
10
  import javax.annotation.Nonnull
9
11
 
10
12
  class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext) :
@@ -26,7 +28,10 @@ class RNMBXRasterSourceManager(reactApplicationContext: ReactApplicationContext)
26
28
  }
27
29
 
28
30
  override fun customEvents(): Map<String, String>? {
29
- return null
31
+ return eventMapOf(
32
+ EventKeys.RASTER_SOURCE_LAYER_CLICK to "onMapboxRasterSourcePress",
33
+ EventKeys.MAP_ANDROID_CALLBACK to "onAndroidCallback"
34
+ )
30
35
  }
31
36
 
32
37
  companion object {
@@ -4,35 +4,37 @@ private fun ns(name: String): String {
4
4
  val namespace = "rct.mapbox"
5
5
  return String.format("%s.%s", namespace, name)
6
6
  }
7
+
7
8
  enum class EventKeys(val value: String) {
8
9
  // map events
9
- MAP_CLICK(ns("map.press")),
10
- MAP_LONG_CLICK(ns("map.longpress")),
11
- MAP_ONCHANGE(ns("map.change")),
12
- MAP_ON_LOCATION_CHANGE(ns("map.location.change")),
13
- MAP_ANDROID_CALLBACK(ns("map.androidcallback")),
14
- MAP_USER_TRACKING_MODE_CHANGE(ns("map.usertrackingmodechange")),
10
+ MAP_CLICK("topPress"),
11
+ MAP_LONG_CLICK("topLongPress"),
12
+ MAP_ONCHANGE("topMapChange"),
13
+ MAP_ON_LOCATION_CHANGE("topLocationChange"),
14
+ MAP_ANDROID_CALLBACK("topAndroidCallback"),
15
+ MAP_USER_TRACKING_MODE_CHANGE("topUserTrackingModeChange"),
15
16
 
16
17
  // point annotation events
17
- POINT_ANNOTATION_SELECTED(ns("pointannotation.selected")),
18
- POINT_ANNOTATION_DESELECTED(ns("pointannotation.deselected")),
19
- POINT_ANNOTATION_DRAG_START(ns("pointannotation.dragstart")),
20
- POINT_ANNOTATION_DRAG(ns("pointannotation.drag")),
21
- POINT_ANNOTATION_DRAG_END(ns("pointannotation.dragend")),
18
+ POINT_ANNOTATION_SELECTED("topMapboxPointAnnotationSelected"),
19
+ POINT_ANNOTATION_DESELECTED("topMapboxPointAnnotationDeselected"),
20
+ POINT_ANNOTATION_DRAG_START("topMapboxPointAnnotationDragStart"),
21
+ POINT_ANNOTATION_DRAG("topMapboxPointAnnotationDrag"),
22
+ POINT_ANNOTATION_DRAG_END("topMapboxPointAnnotationDragEnd"),
22
23
 
23
24
  // source events
24
- SHAPE_SOURCE_LAYER_CLICK(ns("shapesource.layer.pressed")),
25
- VECTOR_SOURCE_LAYER_CLICK(ns("vectorsource.layer.pressed")),
26
- RASTER_SOURCE_LAYER_CLICK(ns("rastersource.layer.pressed")),
25
+ SHAPE_SOURCE_LAYER_CLICK("topMapboxShapeSourcePress"),
26
+ VECTOR_SOURCE_LAYER_CLICK("topMapboxVectorSourcePress"),
27
+ RASTER_SOURCE_LAYER_CLICK("topMapboxRasterSourcePress"),
27
28
 
28
29
  // images event
29
- IMAGES_MISSING(ns("images.missing")),
30
+ IMAGES_MISSING("topImageMissing"),
30
31
 
31
32
  // location events
33
+ // TODO: not sure about this one since it is not registered anywhere
32
34
  USER_LOCATION_UPDATE(ns("user.location.update")),
33
35
 
34
36
  // viewport events
35
- VIEWPORT_STATUS_CHANGE(ns("viewport.statuschange"))
37
+ VIEWPORT_STATUS_CHANGE("topStatusChanged")
36
38
  }
37
39
 
38
40
  fun eventMapOf(vararg values: Pair<EventKeys, String>): Map<String, String> {
@@ -1416,6 +1416,32 @@ extension RNMBXMapView {
1416
1416
  }
1417
1417
  }
1418
1418
 
1419
+ typealias LayerSourceDetails = (source: String?, sourceLayer: String?)
1420
+
1421
+ #if RNMBX_11
1422
+ func getLayerSourceDetails(layer: (any Layer)?) -> LayerSourceDetails? {
1423
+ if let circleLayer = layer as? CircleLayer {
1424
+ return (circleLayer.source, circleLayer.sourceLayer)
1425
+ } else if let fillExtrusionLayer = layer as? FillExtrusionLayer {
1426
+ return (fillExtrusionLayer.source, fillExtrusionLayer.sourceLayer)
1427
+ } else if let fillLayer = layer as? FillLayer {
1428
+ return (fillLayer.source, fillLayer.sourceLayer)
1429
+ } else if let heatmapLayer = layer as? HeatmapLayer {
1430
+ return (heatmapLayer.source, heatmapLayer.sourceLayer)
1431
+ } else if let hillshadeLayer = layer as? HillshadeLayer {
1432
+ return (hillshadeLayer.source, hillshadeLayer.sourceLayer)
1433
+ } else if let lineLayer = layer as? LineLayer {
1434
+ return (lineLayer.source, lineLayer.sourceLayer)
1435
+ } else if let rasterLayer = layer as? RasterLayer {
1436
+ return (rasterLayer.source, rasterLayer.sourceLayer)
1437
+ } else if let symbolLayer = layer as? SymbolLayer {
1438
+ return (symbolLayer.source, symbolLayer.sourceLayer)
1439
+ } else {
1440
+ return nil
1441
+ }
1442
+ }
1443
+ #endif
1444
+
1419
1445
  extension RNMBXMapView {
1420
1446
  func setSourceVisibility(_ visible: Bool, sourceId: String, sourceLayerId: String?) -> Void {
1421
1447
  let style = self.mapboxMap.style
@@ -1424,14 +1450,18 @@ extension RNMBXMapView {
1424
1450
  let layer = logged("setSourceVisibility.layer", info: { "\(layerInfo.id)" }) {
1425
1451
  try style.layer(withId: layerInfo.id)
1426
1452
  }
1453
+
1427
1454
  #if RNMBX_11
1428
- // RNMBX_11_TODO
1455
+ let sourceDetails = getLayerSourceDetails(layer: layer)
1429
1456
  #else
1430
- if let layer = layer {
1431
- if layer.source == sourceId {
1457
+ let sourceDetails: LayerSourceDetails? = (source: layer?.source, sourceLayer: layer?.sourceLayer)
1458
+ #endif
1459
+
1460
+ if let layer = layer, let sourceDetails = sourceDetails {
1461
+ if sourceDetails.source == sourceId {
1432
1462
  var good = true
1433
1463
  if let sourceLayerId = sourceLayerId {
1434
- if sourceLayerId != layer.sourceLayer {
1464
+ if sourceLayerId != sourceDetails.sourceLayer {
1435
1465
  good = false
1436
1466
  }
1437
1467
  }
@@ -1444,7 +1474,6 @@ extension RNMBXMapView {
1444
1474
  }
1445
1475
  }
1446
1476
  }
1447
- #endif
1448
1477
  }
1449
1478
  }
1450
1479
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.1.31",
4
+ "version": "10.1.32-rc.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },