@maplibre/maplibre-react-native 11.0.0-alpha.20 → 11.0.0-alpha.22
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.
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/org/maplibre/reactnative/components/camera/CameraStop.kt +2 -3
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +53 -50
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt +35 -26
- package/android/src/main/java/org/maplibre/reactnative/events/FeatureClickEvent.java +5 -8
- package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +2 -2
- package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.kt +7 -9
- package/ios/components/camera/CameraStop.m +2 -2
- package/ios/components/camera/MLRNCameraComponentView.mm +7 -9
- package/ios/components/camera/MLRNCameraModule.mm +3 -3
- package/ios/components/map-view/MLRNMapTouchEvent.m +14 -8
- package/ios/components/map-view/MLRNMapView.m +16 -10
- package/ios/components/map-view/MLRNMapViewComponentView.mm +24 -30
- package/ios/components/map-view/MLRNMapViewManager.h +8 -8
- package/ios/components/map-view/MLRNMapViewManager.m +23 -34
- package/ios/components/map-view/MLRNMapViewModule.mm +40 -36
- package/lib/commonjs/components/camera/Camera.js +15 -15
- package/lib/commonjs/components/camera/Camera.js.map +1 -1
- package/lib/commonjs/components/camera/CameraNativeComponent.ts +1 -2
- package/lib/commonjs/components/camera/NativeCameraModule.js.map +1 -1
- package/lib/commonjs/components/map-view/MapView.js +8 -11
- package/lib/commonjs/components/map-view/MapView.js.map +1 -1
- package/lib/commonjs/components/map-view/MapViewNativeComponent.ts +7 -6
- package/lib/commonjs/components/map-view/NativeMapViewModule.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/LngLat.js +2 -0
- package/lib/commonjs/types/{Bounds.js.map → LngLat.js.map} +1 -1
- package/lib/commonjs/types/LngLatBounds.js +2 -0
- package/lib/commonjs/types/LngLatBounds.js.map +1 -0
- package/lib/commonjs/types/PixelPoint.js +2 -0
- package/lib/commonjs/types/PixelPoint.js.map +1 -0
- package/lib/commonjs/types/PixelPointBounds.js +2 -0
- package/lib/commonjs/types/PixelPointBounds.js.map +1 -0
- package/lib/commonjs/types/PressEvent.js +4 -0
- package/lib/module/components/camera/Camera.js +15 -15
- package/lib/module/components/camera/Camera.js.map +1 -1
- package/lib/module/components/camera/CameraNativeComponent.ts +1 -2
- package/lib/module/components/camera/NativeCameraModule.js.map +1 -1
- package/lib/module/components/map-view/MapView.js +8 -11
- package/lib/module/components/map-view/MapView.js.map +1 -1
- package/lib/module/components/map-view/MapViewNativeComponent.ts +7 -6
- package/lib/module/components/map-view/NativeMapViewModule.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/LngLat.js +2 -0
- package/lib/module/types/{Bounds.js.map → LngLat.js.map} +1 -1
- package/lib/module/types/LngLatBounds.js +2 -0
- package/lib/module/types/LngLatBounds.js.map +1 -0
- package/lib/module/types/PixelPoint.js +2 -0
- package/lib/module/types/PixelPoint.js.map +1 -0
- package/lib/module/types/PixelPointBounds.js +2 -0
- package/lib/module/types/PixelPointBounds.js.map +1 -0
- package/lib/module/types/PressEvent.js +2 -0
- package/lib/typescript/commonjs/src/components/camera/Camera.d.ts +15 -21
- package/lib/typescript/commonjs/src/components/camera/Camera.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts +1 -2
- package/lib/typescript/commonjs/src/components/camera/CameraNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts +1 -2
- package/lib/typescript/commonjs/src/components/camera/NativeCameraModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts +66 -42
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts +9 -6
- package/lib/typescript/commonjs/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts +12 -26
- package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +6 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/LngLat.d.ts +5 -0
- package/lib/typescript/commonjs/src/types/LngLat.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/LngLatBounds.d.ts +12 -0
- package/lib/typescript/commonjs/src/types/LngLatBounds.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PixelPoint.d.ts +5 -0
- package/lib/typescript/commonjs/src/types/PixelPoint.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PixelPointBounds.d.ts +10 -0
- package/lib/typescript/commonjs/src/types/PixelPointBounds.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PressEvent.d.ts +6 -6
- package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -1
- package/lib/typescript/module/src/components/camera/Camera.d.ts +15 -21
- package/lib/typescript/module/src/components/camera/Camera.d.ts.map +1 -1
- package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts +1 -2
- package/lib/typescript/module/src/components/camera/CameraNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts +1 -2
- package/lib/typescript/module/src/components/camera/NativeCameraModule.d.ts.map +1 -1
- package/lib/typescript/module/src/components/map-view/MapView.d.ts +66 -42
- package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts +9 -6
- package/lib/typescript/module/src/components/map-view/MapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts +12 -26
- package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +6 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/types/LngLat.d.ts +5 -0
- package/lib/typescript/module/src/types/LngLat.d.ts.map +1 -0
- package/lib/typescript/module/src/types/LngLatBounds.d.ts +12 -0
- package/lib/typescript/module/src/types/LngLatBounds.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PixelPoint.d.ts +5 -0
- package/lib/typescript/module/src/types/PixelPoint.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PixelPointBounds.d.ts +10 -0
- package/lib/typescript/module/src/types/PixelPointBounds.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PressEvent.d.ts +6 -6
- package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/camera/Camera.tsx +24 -26
- package/src/components/camera/CameraNativeComponent.ts +1 -2
- package/src/components/camera/NativeCameraModule.ts +1 -2
- package/src/components/map-view/MapView.tsx +106 -62
- package/src/components/map-view/MapViewNativeComponent.ts +7 -6
- package/src/components/map-view/NativeMapViewModule.ts +23 -28
- package/src/index.ts +8 -4
- package/src/types/LngLat.ts +4 -0
- package/src/types/LngLatBounds.ts +11 -0
- package/src/types/PixelPoint.ts +4 -0
- package/src/types/PixelPointBounds.ts +9 -0
- package/src/types/PressEvent.ts +7 -8
- package/lib/commonjs/types/Bounds.js +0 -2
- package/lib/module/types/Bounds.js +0 -2
- package/lib/typescript/commonjs/src/types/Bounds.d.ts +0 -2
- package/lib/typescript/commonjs/src/types/Bounds.d.ts.map +0 -1
- package/lib/typescript/module/src/types/Bounds.d.ts +0 -2
- package/lib/typescript/module/src/types/Bounds.d.ts.map +0 -1
- package/src/types/Bounds.ts +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
2
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
3
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
3
4
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
4
5
|
</manifest>
|
|
@@ -111,9 +111,8 @@ class CameraStop {
|
|
|
111
111
|
): CameraStop {
|
|
112
112
|
val stop = CameraStop()
|
|
113
113
|
|
|
114
|
-
if (readableMap.hasKey("
|
|
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():
|
|
859
|
+
fun getCenter(): WritableArray {
|
|
864
860
|
val cameraPosition = mapLibreMap!!.cameraPosition
|
|
865
861
|
val center = cameraPosition.target!!
|
|
866
862
|
|
|
867
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
908
|
-
|
|
909
|
-
):
|
|
910
|
-
val
|
|
911
|
-
|
|
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
|
-
|
|
931
|
-
|
|
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
|
-
|
|
939
|
+
screenRect,
|
|
936
940
|
filter,
|
|
937
941
|
*(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
|
|
938
942
|
|
|
939
|
-
val
|
|
940
|
-
|
|
941
|
-
com.google.gson.JsonParser.parseString(
|
|
942
|
-
|
|
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):
|
|
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:
|
|
956
|
+
val payload: WritableArray = Arguments.createArray()
|
|
951
957
|
|
|
952
|
-
payload.
|
|
953
|
-
payload.
|
|
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):
|
|
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
|
|
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
|
|
971
|
+
return GeoJSONUtils.fromLatLng(latLng)
|
|
969
972
|
}
|
|
970
973
|
|
|
971
974
|
fun takeSnap(writeToDisk: Boolean, callback: (String) -> Unit) {
|
package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt
CHANGED
|
@@ -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,
|
|
66
|
+
reactTag: Double, lngLat: ReadableArray, promise: Promise
|
|
69
67
|
) {
|
|
70
68
|
withViewportOnUIThread(reactTag, promise) { mapView ->
|
|
71
69
|
promise.resolve(
|
|
72
70
|
mapView.project(
|
|
73
|
-
|
|
71
|
+
GeoJSONUtils.toLatLng(lngLat)!!
|
|
74
72
|
)
|
|
75
73
|
)
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
override fun unproject(
|
|
80
|
-
reactTag: Double,
|
|
78
|
+
reactTag: Double, pixelPoint: ReadableArray, promise: Promise
|
|
81
79
|
) {
|
|
82
80
|
withViewportOnUIThread(reactTag, promise) { mapView ->
|
|
83
|
-
promise.resolve(mapView.unproject(ConvertUtils.toPointF(
|
|
81
|
+
promise.resolve(mapView.unproject(ConvertUtils.toPointF(pixelPoint)))
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
override fun
|
|
85
|
+
override fun queryRenderedFeaturesWithPoint(
|
|
88
86
|
reactTag: Double,
|
|
89
|
-
|
|
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.
|
|
97
|
-
|
|
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
|
-
|
|
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.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
53
|
-
point.
|
|
54
|
-
point.
|
|
55
|
-
map.
|
|
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
|
}
|
|
@@ -203,8 +203,8 @@ public class ConvertUtils {
|
|
|
203
203
|
return list;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
public static PointF toPointF(
|
|
207
|
-
return new PointF((float) map.getDouble(
|
|
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
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return
|
|
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[@"
|
|
37
|
-
stop.center = [MLRNUtils fromLongitude:args[@"
|
|
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.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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.
|
|
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.
|
|
143
|
-
stop[@"
|
|
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.
|
|
54
|
-
|
|
55
|
-
stopDict[@"
|
|
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
|
-
@"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
@"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
@"
|
|
808
|
-
|
|
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],
|