@maplibre/maplibre-react-native 11.0.0-alpha.21 → 11.0.0-alpha.23

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.
Files changed (120) hide show
  1. package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraStop.kt +2 -3
  2. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +53 -50
  3. package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt +35 -26
  4. package/android/src/main/java/org/maplibre/reactnative/events/FeatureClickEvent.java +5 -8
  5. package/android/src/main/java/org/maplibre/reactnative/events/MapPressEvent.kt +6 -4
  6. package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +2 -2
  7. package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.kt +7 -9
  8. package/ios/components/camera/CameraStop.m +2 -2
  9. package/ios/components/camera/MLRNCameraComponentView.mm +7 -9
  10. package/ios/components/camera/MLRNCameraModule.mm +3 -3
  11. package/ios/components/map-view/MLRNMapTouchEvent.m +14 -8
  12. package/ios/components/map-view/MLRNMapView.m +16 -10
  13. package/ios/components/map-view/MLRNMapViewComponentView.mm +24 -30
  14. package/ios/components/map-view/MLRNMapViewManager.h +8 -8
  15. package/ios/components/map-view/MLRNMapViewManager.m +23 -34
  16. package/ios/components/map-view/MLRNMapViewModule.mm +40 -36
  17. package/lib/commonjs/components/camera/Camera.js +15 -15
  18. package/lib/commonjs/components/camera/Camera.js.map +1 -1
  19. package/lib/commonjs/components/camera/CameraNativeComponent.ts +1 -2
  20. package/lib/commonjs/components/camera/NativeCameraModule.js.map +1 -1
  21. package/lib/commonjs/components/map-view/MapView.js +8 -11
  22. package/lib/commonjs/components/map-view/MapView.js.map +1 -1
  23. package/lib/commonjs/components/map-view/MapViewNativeComponent.ts +7 -6
  24. package/lib/commonjs/components/map-view/NativeMapViewModule.js.map +1 -1
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/types/LngLat.js +2 -0
  27. package/lib/commonjs/types/{Bounds.js.map → LngLat.js.map} +1 -1
  28. package/lib/commonjs/types/LngLatBounds.js +2 -0
  29. package/lib/commonjs/types/LngLatBounds.js.map +1 -0
  30. package/lib/commonjs/types/PixelPoint.js +2 -0
  31. package/lib/commonjs/types/PixelPoint.js.map +1 -0
  32. package/lib/commonjs/types/PixelPointBounds.js +2 -0
  33. package/lib/commonjs/types/PixelPointBounds.js.map +1 -0
  34. package/lib/commonjs/types/PressEvent.js +4 -0
  35. package/lib/module/components/camera/Camera.js +15 -15
  36. package/lib/module/components/camera/Camera.js.map +1 -1
  37. package/lib/module/components/camera/CameraNativeComponent.ts +1 -2
  38. package/lib/module/components/camera/NativeCameraModule.js.map +1 -1
  39. package/lib/module/components/map-view/MapView.js +8 -11
  40. package/lib/module/components/map-view/MapView.js.map +1 -1
  41. package/lib/module/components/map-view/MapViewNativeComponent.ts +7 -6
  42. package/lib/module/components/map-view/NativeMapViewModule.js.map +1 -1
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/types/LngLat.js +2 -0
  45. package/lib/module/types/{Bounds.js.map → LngLat.js.map} +1 -1
  46. package/lib/module/types/LngLatBounds.js +2 -0
  47. package/lib/module/types/LngLatBounds.js.map +1 -0
  48. package/lib/module/types/PixelPoint.js +2 -0
  49. package/lib/module/types/PixelPoint.js.map +1 -0
  50. package/lib/module/types/PixelPointBounds.js +2 -0
  51. package/lib/module/types/PixelPointBounds.js.map +1 -0
  52. package/lib/module/types/PressEvent.js +2 -0
  53. package/lib/typescript/commonjs/src/components/camera/Camera.d.ts +15 -21
  54. package/lib/typescript/commonjs/src/components/camera/Camera.d.ts.map +1 -1
  55. package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts +1 -2
  56. package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts +1 -2
  58. package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts +66 -42
  60. package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts +9 -6
  62. package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts +12 -26
  64. package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/src/index.d.ts +6 -3
  66. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/src/types/LngLat.d.ts +5 -0
  68. package/lib/typescript/commonjs/src/types/LngLat.d.ts.map +1 -0
  69. package/lib/typescript/commonjs/src/types/LngLatBounds.d.ts +12 -0
  70. package/lib/typescript/commonjs/src/types/LngLatBounds.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/src/types/PixelPoint.d.ts +5 -0
  72. package/lib/typescript/commonjs/src/types/PixelPoint.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/src/types/PixelPointBounds.d.ts +10 -0
  74. package/lib/typescript/commonjs/src/types/PixelPointBounds.d.ts.map +1 -0
  75. package/lib/typescript/commonjs/src/types/PressEvent.d.ts +6 -6
  76. package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -1
  77. package/lib/typescript/module/src/components/camera/Camera.d.ts +15 -21
  78. package/lib/typescript/module/src/components/camera/Camera.d.ts.map +1 -1
  79. package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts +1 -2
  80. package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts.map +1 -1
  81. package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts +1 -2
  82. package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts.map +1 -1
  83. package/lib/typescript/module/src/components/map-view/MapView.d.ts +66 -42
  84. package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
  85. package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts +9 -6
  86. package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -1
  87. package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts +12 -26
  88. package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
  89. package/lib/typescript/module/src/index.d.ts +6 -3
  90. package/lib/typescript/module/src/index.d.ts.map +1 -1
  91. package/lib/typescript/module/src/types/LngLat.d.ts +5 -0
  92. package/lib/typescript/module/src/types/LngLat.d.ts.map +1 -0
  93. package/lib/typescript/module/src/types/LngLatBounds.d.ts +12 -0
  94. package/lib/typescript/module/src/types/LngLatBounds.d.ts.map +1 -0
  95. package/lib/typescript/module/src/types/PixelPoint.d.ts +5 -0
  96. package/lib/typescript/module/src/types/PixelPoint.d.ts.map +1 -0
  97. package/lib/typescript/module/src/types/PixelPointBounds.d.ts +10 -0
  98. package/lib/typescript/module/src/types/PixelPointBounds.d.ts.map +1 -0
  99. package/lib/typescript/module/src/types/PressEvent.d.ts +6 -6
  100. package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -1
  101. package/package.json +2 -2
  102. package/src/components/camera/Camera.tsx +24 -26
  103. package/src/components/camera/CameraNativeComponent.ts +1 -2
  104. package/src/components/camera/NativeCameraModule.ts +1 -2
  105. package/src/components/map-view/MapView.tsx +106 -62
  106. package/src/components/map-view/MapViewNativeComponent.ts +7 -6
  107. package/src/components/map-view/NativeMapViewModule.ts +23 -28
  108. package/src/index.ts +8 -4
  109. package/src/types/LngLat.ts +4 -0
  110. package/src/types/LngLatBounds.ts +11 -0
  111. package/src/types/PixelPoint.ts +4 -0
  112. package/src/types/PixelPointBounds.ts +9 -0
  113. package/src/types/PressEvent.ts +7 -8
  114. package/lib/commonjs/types/Bounds.js +0 -2
  115. package/lib/module/types/Bounds.js +0 -2
  116. package/lib/typescript/commonjs/src/types/Bounds.d.ts +0 -2
  117. package/lib/typescript/commonjs/src/types/Bounds.d.ts.map +0 -1
  118. package/lib/typescript/module/src/types/Bounds.d.ts +0 -2
  119. package/lib/typescript/module/src/types/Bounds.d.ts.map +0 -1
  120. package/src/types/Bounds.ts +0 -1
@@ -111,9 +111,8 @@ class CameraStop {
111
111
  ): CameraStop {
112
112
  val stop = CameraStop()
113
113
 
114
- if (readableMap.hasKey("longitude") && readableMap.hasKey("latitude")) {
115
- stop.center =
116
- LatLng(readableMap.getDouble("latitude"), readableMap.getDouble("longitude"))
114
+ if (readableMap.hasKey("center")) {
115
+ stop.center = GeoJSONUtils.toLatLng(readableMap.getArray("center"))
117
116
  } else if (readableMap.hasKey("bounds")) {
118
117
  stop.bounds = GeoJSONUtils.toLatLngBounds(readableMap.getArray("bounds"))
119
118
  }
@@ -13,6 +13,7 @@ import android.view.MotionEvent
13
13
  import android.view.View
14
14
  import android.view.ViewGroup
15
15
  import android.widget.FrameLayout
16
+ import com.facebook.react.bridge.Arguments
16
17
  import com.facebook.react.bridge.LifecycleEventListener
17
18
  import com.facebook.react.bridge.ReactContext
18
19
  import com.facebook.react.bridge.ReadableArray
@@ -23,13 +24,11 @@ import com.facebook.react.bridge.WritableNativeArray
23
24
  import com.facebook.react.bridge.WritableNativeMap
24
25
  import com.facebook.react.uimanager.UIManagerHelper
25
26
  import com.facebook.react.uimanager.events.EventDispatcher
26
- import com.google.gson.JsonObject
27
27
  import org.json.JSONException
28
28
  import org.json.JSONObject
29
29
  import org.maplibre.android.camera.CameraPosition
30
30
  import org.maplibre.android.camera.CameraUpdate
31
31
  import org.maplibre.android.geometry.LatLng
32
- import org.maplibre.android.geometry.LatLngBounds
33
32
  import org.maplibre.android.gestures.MoveGestureDetector
34
33
  import org.maplibre.android.log.Logger
35
34
  import org.maplibre.android.maps.AttributionDialogManager
@@ -39,7 +38,6 @@ import org.maplibre.android.maps.MapView
39
38
  import org.maplibre.android.maps.OnMapReadyCallback
40
39
  import org.maplibre.android.maps.Style
41
40
  import org.maplibre.android.maps.Style.OnStyleLoaded
42
- import org.maplibre.android.plugins.annotation.OnSymbolClickListener
43
41
  import org.maplibre.android.plugins.annotation.OnSymbolDragListener
44
42
  import org.maplibre.android.plugins.annotation.Symbol
45
43
  import org.maplibre.android.plugins.annotation.SymbolManager
@@ -48,7 +46,6 @@ import org.maplibre.android.style.layers.Layer
48
46
  import org.maplibre.android.style.layers.Property
49
47
  import org.maplibre.android.style.layers.PropertyFactory
50
48
  import org.maplibre.geojson.Feature
51
- import org.maplibre.geojson.FeatureCollection
52
49
  import org.maplibre.reactnative.R
53
50
  import org.maplibre.reactnative.components.AbstractMapFeature
54
51
  import org.maplibre.reactnative.components.annotations.MLRNMarkerView
@@ -274,8 +271,7 @@ open class MLRNMapView(
274
271
  children().remove(child)
275
272
  }
276
273
 
277
- private fun children() =
278
- queuedChildren?.takeIf { it.isNotEmpty() } ?: children
274
+ private fun children() = queuedChildren?.takeIf { it.isNotEmpty() } ?: children
279
275
 
280
276
  val featureCount: Int get() = children().size
281
277
 
@@ -860,15 +856,11 @@ open class MLRNMapView(
860
856
  { compassMargins = it })
861
857
  }
862
858
 
863
- fun getCenter(): WritableMap {
859
+ fun getCenter(): WritableArray {
864
860
  val cameraPosition = mapLibreMap!!.cameraPosition
865
861
  val center = cameraPosition.target!!
866
862
 
867
- val payload: WritableMap = WritableNativeMap()
868
- payload.putDouble("longitude", center.longitude)
869
- payload.putDouble("latitude", center.latitude)
870
-
871
- return payload
863
+ return GeoJSONUtils.fromLatLng(center)
872
864
  }
873
865
 
874
866
  fun getZoom(): Double {
@@ -880,7 +872,8 @@ open class MLRNMapView(
880
872
  fun getBearing(): Double {
881
873
  val cameraPosition = mapLibreMap!!.cameraPosition
882
874
 
883
- return cameraPosition.bearing
875
+ // Convert -0.0 to 0.0
876
+ return cameraPosition.bearing + 0.0
884
877
  }
885
878
 
886
879
  fun getPitch(): Double {
@@ -895,7 +888,8 @@ open class MLRNMapView(
895
888
  }
896
889
 
897
890
  fun getViewState(): WritableMap {
898
- val payload = this.getCenter()
891
+ val payload = Arguments.createMap();
892
+ payload.putArray("center", getCenter())
899
893
  payload.putDouble("zoom", getZoom())
900
894
  payload.putDouble("bearing", getBearing())
901
895
  payload.putDouble("pitch", getPitch())
@@ -904,68 +898,77 @@ open class MLRNMapView(
904
898
  return payload
905
899
  }
906
900
 
907
- fun queryRenderedFeaturesWithCoordinate(
908
- latLng: LatLng, layers: ReadableArray?, filter: Expression?,
909
- ): WritableMap {
910
- val features =
911
- mapLibreMap!!.queryRenderedFeatures(
912
- mapLibreMap!!.projection.toScreenLocation(latLng),
913
- filter,
914
- *(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
901
+ fun queryRenderedFeaturesWithPoint(
902
+ point: PointF, layers: ReadableArray?, filter: Expression?,
903
+ ): WritableArray {
904
+ val density = this.displayDensity
905
+ val screenPoint = PointF(point.x * density, point.y * density)
915
906
 
907
+ val features = mapLibreMap!!.queryRenderedFeatures(
908
+ screenPoint,
909
+ filter,
910
+ *(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
916
911
 
917
- val featureCollection = FeatureCollection.fromFeatures(features)
918
- val jsonObject: JsonObject =
919
- com.google.gson.JsonParser.parseString(featureCollection.toJson()).asJsonObject
920
- return ConvertUtils.toWritableMap(jsonObject)
921
- }
922
912
 
913
+ val result = Arguments.createArray()
914
+ for (feature in features) {
915
+ val jsonObject = com.google.gson.JsonParser.parseString(feature.toJson()).asJsonObject
916
+ result.pushMap(ConvertUtils.toWritableMap(jsonObject))
917
+ }
918
+ return result
919
+ }
923
920
 
924
- fun queryRenderedFeaturesWithBounds(
925
- bounds: LatLngBounds, layers: ReadableArray?, filter: Expression?,
926
- ): WritableMap {
927
- val swPoint = mapLibreMap!!.projection.toScreenLocation(bounds.southWest)
928
- val nePoint = mapLibreMap!!.projection.toScreenLocation(bounds.northEast)
929
921
 
930
- val rect = RectF(
931
- swPoint.x, nePoint.y, nePoint.x, swPoint.y
932
- )
922
+ fun queryRenderedFeaturesWithRect(
923
+ rect: RectF?, layers: ReadableArray?, filter: Expression?,
924
+ ): WritableArray {
925
+ val screenRect = if (rect == null) {
926
+ val width = this.width.toFloat()
927
+ val height = this.height.toFloat()
928
+ RectF(0f, 0f, width, height)
929
+ } else {
930
+ RectF(
931
+ rect.left * this.displayDensity,
932
+ rect.top * this.displayDensity,
933
+ rect.right * this.displayDensity,
934
+ rect.bottom * this.displayDensity
935
+ )
936
+ }
933
937
 
934
938
  val features = mapLibreMap!!.queryRenderedFeatures(
935
- rect,
939
+ screenRect,
936
940
  filter,
937
941
  *(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
938
942
 
939
- val featureCollection = FeatureCollection.fromFeatures(features)
940
- val jsonObject =
941
- com.google.gson.JsonParser.parseString(featureCollection.toJson()).asJsonObject
942
- return ConvertUtils.toWritableMap(jsonObject)
943
+ val result = Arguments.createArray()
944
+ for (feature in features) {
945
+ val jsonObject = com.google.gson.JsonParser.parseString(feature.toJson()).asJsonObject
946
+ result.pushMap(ConvertUtils.toWritableMap(jsonObject))
947
+ }
948
+ return result
943
949
  }
944
950
 
945
- fun project(mapCoordinate: LatLng): WritableMap {
951
+ fun project(mapCoordinate: LatLng): WritableArray {
946
952
  val pointInView = mapLibreMap!!.projection.toScreenLocation(mapCoordinate)
947
953
  val density = this.displayDensity
948
954
  pointInView.x /= density
949
955
  pointInView.y /= density
950
- val payload: WritableMap = WritableNativeMap()
956
+ val payload: WritableArray = Arguments.createArray()
951
957
 
952
- payload.putDouble("locationX", pointInView.x.toDouble())
953
- payload.putDouble("locationY", pointInView.y.toDouble())
958
+ payload.pushDouble(pointInView.x.toDouble())
959
+ payload.pushDouble(pointInView.y.toDouble())
954
960
 
955
961
  return payload
956
962
  }
957
963
 
958
- fun unproject(pointInView: PointF): WritableMap {
964
+ fun unproject(pointInView: PointF): WritableArray {
959
965
  val density = this.displayDensity
960
966
  pointInView.x *= density
961
967
  pointInView.y *= density
962
968
 
963
- val mapCoordinate = mapLibreMap!!.projection.fromScreenLocation(pointInView)
964
- val payload: WritableMap = WritableNativeMap()
965
- payload.putDouble("longitude", mapCoordinate.longitude)
966
- payload.putDouble("latitude", mapCoordinate.latitude)
969
+ val latLng = mapLibreMap!!.projection.fromScreenLocation(pointInView)
967
970
 
968
- return payload
971
+ return GeoJSONUtils.fromLatLng(latLng)
969
972
  }
970
973
 
971
974
  fun takeSnap(writeToDisk: Boolean, callback: (String) -> Unit) {
@@ -1,16 +1,14 @@
1
1
  package org.maplibre.reactnative.components.mapview
2
2
 
3
+ import android.graphics.RectF
3
4
  import com.facebook.react.bridge.Promise
4
5
  import com.facebook.react.bridge.ReactApplicationContext
5
6
  import com.facebook.react.bridge.ReadableArray
6
- import com.facebook.react.bridge.ReadableMap
7
7
  import com.facebook.react.module.annotations.ReactModule
8
- import org.maplibre.android.camera.CameraUpdateFactory.newLatLngBounds
9
- import org.maplibre.android.geometry.LatLng
10
- import org.maplibre.android.geometry.LatLngBounds
11
8
  import org.maplibre.reactnative.NativeMapViewModuleSpec
12
9
  import org.maplibre.reactnative.utils.ConvertUtils
13
10
  import org.maplibre.reactnative.utils.ExpressionParser
11
+ import org.maplibre.reactnative.utils.GeoJSONUtils
14
12
  import org.maplibre.reactnative.utils.ReactTag
15
13
  import org.maplibre.reactnative.utils.ReactTagResolver
16
14
 
@@ -65,36 +63,36 @@ class MLRNMapViewModule(
65
63
  }
66
64
 
67
65
  override fun project(
68
- reactTag: Double, coordinate: ReadableMap, promise: Promise
66
+ reactTag: Double, lngLat: ReadableArray, promise: Promise
69
67
  ) {
70
68
  withViewportOnUIThread(reactTag, promise) { mapView ->
71
69
  promise.resolve(
72
70
  mapView.project(
73
- LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"))
71
+ GeoJSONUtils.toLatLng(lngLat)!!
74
72
  )
75
73
  )
76
74
  }
77
75
  }
78
76
 
79
77
  override fun unproject(
80
- reactTag: Double, point: ReadableMap, promise: Promise
78
+ reactTag: Double, pixelPoint: ReadableArray, promise: Promise
81
79
  ) {
82
80
  withViewportOnUIThread(reactTag, promise) { mapView ->
83
- promise.resolve(mapView.unproject(ConvertUtils.toPointF(point)))
81
+ promise.resolve(mapView.unproject(ConvertUtils.toPointF(pixelPoint)))
84
82
  }
85
83
  }
86
84
 
87
- override fun queryRenderedFeaturesWithCoordinate(
85
+ override fun queryRenderedFeaturesWithPoint(
88
86
  reactTag: Double,
89
- coordinate: ReadableMap,
87
+ pixelPoint: ReadableArray,
90
88
  layers: ReadableArray?,
91
89
  filter: ReadableArray?,
92
90
  promise: Promise
93
91
  ) {
94
92
  withViewportOnUIThread(reactTag, promise) { mapView ->
95
93
  promise.resolve(
96
- mapView.queryRenderedFeaturesWithCoordinate(
97
- LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude")),
94
+ mapView.queryRenderedFeaturesWithPoint(
95
+ ConvertUtils.toPointF(pixelPoint),
98
96
  layers,
99
97
  ExpressionParser.from(filter),
100
98
  )
@@ -104,24 +102,33 @@ class MLRNMapViewModule(
104
102
 
105
103
  override fun queryRenderedFeaturesWithBounds(
106
104
  reactTag: Double,
107
- bounds: ReadableArray?,
105
+ pixelPointBounds: ReadableArray?,
108
106
  layers: ReadableArray?,
109
107
  filter: ReadableArray?,
110
108
  promise: Promise
111
109
  ) {
110
+
111
+
112
112
  withViewportOnUIThread(reactTag, promise) { mapView ->
113
+ val rect = if (pixelPointBounds == null) {
114
+ null
115
+ } else {
116
+ val topLeft = pixelPointBounds.getArray(0)
117
+ val bottomRight = pixelPointBounds.getArray(1)
118
+
119
+ RectF(
120
+ topLeft!!.getDouble(0).toFloat(),
121
+ topLeft.getDouble(1).toFloat(),
122
+ bottomRight!!.getDouble(0).toFloat(),
123
+ bottomRight.getDouble(1).toFloat()
124
+ )
125
+ }
126
+
113
127
  promise.resolve(
114
- mapView.queryRenderedFeaturesWithBounds(
115
- if (bounds != null && bounds.size() == 4)
116
- LatLngBounds.from(
117
- bounds.getDouble(3),
118
- bounds.getDouble(2),
119
- bounds.getDouble(1),
120
- bounds.getDouble(0)
121
- )
122
- else
123
- LatLngBounds.world(),
124
- layers, ExpressionParser.from(filter),
128
+ mapView.queryRenderedFeaturesWithRect(
129
+ rect,
130
+ layers,
131
+ ExpressionParser.from(filter),
125
132
  )
126
133
  )
127
134
  }
@@ -135,7 +142,8 @@ class MLRNMapViewModule(
135
142
  promise: Promise
136
143
  ) {
137
144
  withViewportOnUIThread(reactTag, promise) {
138
- promise.resolve(it.setSourceVisibility(visible, sourceId, sourceLayerId))
145
+ it.setSourceVisibility(visible, sourceId, sourceLayerId)
146
+ promise.resolve(null)
139
147
  }
140
148
  }
141
149
 
@@ -153,7 +161,8 @@ class MLRNMapViewModule(
153
161
  reactTag: Double, promise: Promise
154
162
  ) {
155
163
  withViewportOnUIThread(reactTag, promise) {
156
- promise.resolve(it.showAttribution())
164
+ it.showAttribution()
165
+ promise.resolve(null)
157
166
  }
158
167
  }
159
168
  }
@@ -44,15 +44,12 @@ public class FeatureClickEvent extends AbstractEvent {
44
44
  }
45
45
  map.putArray("features", features);
46
46
 
47
- WritableMap coordinates = Arguments.createMap();
48
- coordinates.putDouble("latitude", mLatLng.getLatitude());
49
- coordinates.putDouble("longitude", mLatLng.getLongitude());
50
- map.putMap("coordinates", coordinates);
47
+ map.putArray("lngLat", GeoJSONUtils.fromLatLng(mLatLng));
51
48
 
52
- WritableMap point = Arguments.createMap();
53
- point.putDouble("x", mPoint.x);
54
- point.putDouble("y", mPoint.y);
55
- map.putMap("point", point);
49
+ WritableArray point = Arguments.createArray();
50
+ point.pushDouble( mPoint.x);
51
+ point.pushDouble( mPoint.y);
52
+ map.putArray("point", point);
56
53
 
57
54
  return map;
58
55
  }
@@ -5,6 +5,7 @@ import com.facebook.react.bridge.Arguments
5
5
  import com.facebook.react.bridge.WritableMap
6
6
  import com.facebook.react.uimanager.events.Event
7
7
  import org.maplibre.android.geometry.LatLng
8
+ import org.maplibre.reactnative.utils.GeoJSONUtils
8
9
 
9
10
  class MapPressEvent(
10
11
  surfaceId: Int,
@@ -18,10 +19,11 @@ class MapPressEvent(
18
19
 
19
20
  override fun getEventData(): WritableMap {
20
21
  return Arguments.createMap().apply {
21
- putDouble("longitude", latLng.longitude)
22
- putDouble("latitude", latLng.latitude)
23
- putDouble("locationX", screenPoint.x.toDouble())
24
- putDouble("locationY", screenPoint.y.toDouble())
22
+ putArray("lngLat", GeoJSONUtils.fromLatLng(latLng))
23
+ putArray("point", Arguments.createArray().apply {
24
+ pushDouble(screenPoint.x.toDouble())
25
+ pushDouble(screenPoint.y.toDouble())
26
+ })
25
27
  }
26
28
  }
27
29
  }
@@ -203,8 +203,8 @@ public class ConvertUtils {
203
203
  return list;
204
204
  }
205
205
 
206
- public static PointF toPointF(ReadableMap map) {
207
- return new PointF((float) map.getDouble("locationX"), (float) map.getDouble("locationY"));
206
+ public static PointF toPointF(ReadableArray map) {
207
+ return new PointF((float) map.getDouble(0), (float) map.getDouble(1));
208
208
  }
209
209
 
210
210
  public static RectF toRectF(ReadableArray array) {
@@ -224,12 +224,13 @@ object GeoJSONUtils {
224
224
  return geometry
225
225
  }
226
226
 
227
+ @JvmStatic
227
228
  fun fromLatLng(latLng: LatLng): WritableArray {
228
- val coords = doubleArrayOf(latLng.longitude, latLng.latitude)
229
- val writableCoords: WritableArray = WritableNativeArray()
230
- writableCoords.pushDouble(coords[0])
231
- writableCoords.pushDouble(coords[1])
232
- return writableCoords
229
+ val coordinates: WritableArray = WritableNativeArray()
230
+ coordinates.pushDouble(latLng.longitude)
231
+ coordinates.pushDouble(latLng.latitude)
232
+
233
+ return coordinates
233
234
  }
234
235
 
235
236
  @JvmStatic
@@ -289,10 +290,7 @@ object GeoJSONUtils {
289
290
  fun toLatLngBounds(array: ReadableArray?): LatLngBounds? {
290
291
  if (array != null && array.size() == 4) {
291
292
  return LatLngBounds.from(
292
- array.getDouble(3),
293
- array.getDouble(2),
294
- array.getDouble(1),
295
- array.getDouble(0)
293
+ array.getDouble(3), array.getDouble(2), array.getDouble(1), array.getDouble(0)
296
294
  )
297
295
  }
298
296
 
@@ -33,8 +33,8 @@
33
33
  + (CameraStop *)fromDictionary:(NSDictionary *)args {
34
34
  CameraStop *stop = [[CameraStop alloc] init];
35
35
 
36
- if (args[@"longitude"] && args[@"latitude"]) {
37
- stop.center = [MLRNUtils fromLongitude:args[@"longitude"] latitude:args[@"latitude"]];
36
+ if (args[@"center"]) {
37
+ stop.center = [MLRNUtils fromLongitude:args[@"center"][0] latitude:args[@"center"][1]];
38
38
  }
39
39
 
40
40
  if (args[@"zoom"]) {
@@ -89,10 +89,10 @@ using namespace facebook::react;
89
89
  if (_view.initialViewState == nil) {
90
90
  NSMutableDictionary *initialViewState = [NSMutableDictionary dictionary];
91
91
 
92
- if (newViewProps.initialViewState.longitude != -360 &&
93
- newViewProps.initialViewState.latitude != -360) {
94
- initialViewState[@"longitude"] = @(newViewProps.initialViewState.longitude);
95
- initialViewState[@"latitude"] = @(newViewProps.initialViewState.latitude);
92
+ if (newViewProps.initialViewState.center.size() == 2) {
93
+ initialViewState[@"center"] = @[
94
+ @(newViewProps.initialViewState.center[0]), @(newViewProps.initialViewState.center[1])
95
+ ];
96
96
  } else if (newViewProps.initialViewState.bounds.size() == 4) {
97
97
  initialViewState[@"bounds"] = @[
98
98
  @(newViewProps.initialViewState.bounds[0]), @(newViewProps.initialViewState.bounds[1]),
@@ -122,8 +122,7 @@ using namespace facebook::react;
122
122
 
123
123
  BOOL updateCamera = NO;
124
124
 
125
- if (oldViewProps.stop.longitude != newViewProps.stop.longitude ||
126
- oldViewProps.stop.latitude != newViewProps.stop.latitude ||
125
+ if (oldViewProps.stop.center != newViewProps.stop.center ||
127
126
 
128
127
  oldViewProps.stop.bounds != newViewProps.stop.bounds ||
129
128
  oldViewProps.stop.padding.top != newViewProps.stop.padding.top ||
@@ -139,9 +138,8 @@ using namespace facebook::react;
139
138
  oldViewProps.stop.easing != newViewProps.stop.easing) {
140
139
  NSMutableDictionary *stop = [NSMutableDictionary dictionary];
141
140
 
142
- if (newViewProps.stop.longitude != -360 && newViewProps.stop.latitude != -360) {
143
- stop[@"longitude"] = @(newViewProps.stop.longitude);
144
- stop[@"latitude"] = @(newViewProps.stop.latitude);
141
+ if (newViewProps.stop.center.size() == 2) {
142
+ stop[@"center"] = @[ @(newViewProps.stop.center[0]), @(newViewProps.stop.center[1]) ];
145
143
  } else if (newViewProps.stop.bounds.size() == 4) {
146
144
  stop[@"bounds"] = @[
147
145
  @(newViewProps.stop.bounds[0]), @(newViewProps.stop.bounds[1]),
@@ -50,9 +50,9 @@
50
50
  reject:(RCTPromiseRejectBlock)reject {
51
51
  NSMutableDictionary<NSString *, id> *stopDict = [NSMutableDictionary dictionary];
52
52
 
53
- if (stop.longitude().has_value() && stop.latitude().has_value()) {
54
- stopDict[@"longitude"] = @(stop.longitude().value());
55
- stopDict[@"latitude"] = @(stop.latitude().value());
53
+ if (stop.center().has_value() && stop.center().value().size() == 2) {
54
+ NSArray<NSNumber *> *center = @[ @(stop.center().value()[0]), @(stop.center().value()[1]) ];
55
+ stopDict[@"center"] = center;
56
56
  } else if (stop.bounds().has_value() && stop.bounds().value().size() == 4) {
57
57
  NSArray<NSNumber *> *bounds = @[
58
58
  @(stop.bounds().value()[0]), @(stop.bounds().value()[1]), @(stop.bounds().value()[2]),
@@ -10,18 +10,24 @@
10
10
  feature.coordinate = _coordinate;
11
11
  if (_id == nil) {
12
12
  feature.attributes = @{
13
- @"longitude" : [NSNumber numberWithDouble:_coordinate.longitude],
14
- @"latitude" : [NSNumber numberWithDouble:_coordinate.latitude],
15
- @"locationX" : [NSNumber numberWithDouble:_screenPoint.x],
16
- @"locationY" : [NSNumber numberWithDouble:_screenPoint.y]
13
+ @"lngLat" : @[
14
+ [NSNumber numberWithDouble:_coordinate.longitude],
15
+ [NSNumber numberWithDouble:_coordinate.latitude]
16
+ ],
17
+ @"point" : @[
18
+ [NSNumber numberWithDouble:_screenPoint.x], [NSNumber numberWithDouble:_screenPoint.y]
19
+ ]
17
20
  };
18
21
  } else {
19
22
  feature.attributes = @{
20
23
  @"id" : _id,
21
- @"longitude" : [NSNumber numberWithDouble:_coordinate.longitude],
22
- @"latitude" : [NSNumber numberWithDouble:_coordinate.latitude],
23
- @"locationX" : [NSNumber numberWithDouble:_screenPoint.x],
24
- @"locationY" : [NSNumber numberWithDouble:_screenPoint.y]
24
+ @"lngLat" : @[
25
+ [NSNumber numberWithDouble:_coordinate.longitude],
26
+ [NSNumber numberWithDouble:_coordinate.latitude]
27
+ ],
28
+ @"point" : @[
29
+ [NSNumber numberWithDouble:_screenPoint.x], [NSNumber numberWithDouble:_screenPoint.y]
30
+ ]
25
31
  };
26
32
  }
27
33
  return [feature geoJSONDictionary];
@@ -294,14 +294,18 @@ static double const M2PI = M_PI * 2;
294
294
  CLLocationCoordinate2D coordinate = [mapView convertPoint:screenPoint
295
295
  toCoordinateFromView:mapView];
296
296
 
297
- MLRNEvent *event = [MLRNEvent makeEvent:eventType
298
- withPayload:@{
299
- @"longitude" : [NSNumber numberWithDouble:coordinate.longitude],
300
- @"latitude" : [NSNumber numberWithDouble:coordinate.latitude],
301
- @"locationX" : [NSNumber numberWithDouble:screenPoint.x],
302
- @"locationY" : [NSNumber numberWithDouble:screenPoint.y],
303
- @"features" : geoJSONDicts,
304
- }];
297
+ MLRNEvent *event = [MLRNEvent
298
+ makeEvent:eventType
299
+ withPayload:@{
300
+ @"lngLat" : @[
301
+ [NSNumber numberWithDouble:coordinate.longitude],
302
+ [NSNumber numberWithDouble:coordinate.latitude]
303
+ ],
304
+ @"point" : @[
305
+ [NSNumber numberWithDouble:screenPoint.x], [NSNumber numberWithDouble:screenPoint.y]
306
+ ],
307
+ @"features" : geoJSONDicts,
308
+ }];
305
309
 
306
310
  source.onPress([event toJSON]);
307
311
 
@@ -804,8 +808,10 @@ static double const M2PI = M_PI * 2;
804
808
  MLRNMapView *rctMapView = (MLRNMapView *)mapView;
805
809
 
806
810
  NSDictionary *viewState = @{
807
- @"longitude" : [NSNumber numberWithDouble:mapView.centerCoordinate.longitude],
808
- @"latitude" : [NSNumber numberWithDouble:mapView.centerCoordinate.latitude],
811
+ @"center" : @[
812
+ [NSNumber numberWithDouble:mapView.centerCoordinate.longitude],
813
+ [NSNumber numberWithDouble:mapView.centerCoordinate.latitude]
814
+ ],
809
815
  @"zoom" : [NSNumber numberWithDouble:mapView.zoomLevel],
810
816
  @"pitch" : [NSNumber numberWithDouble:mapView.camera.pitch],
811
817
  @"bearing" : [NSNumber numberWithDouble:mapView.camera.heading],