@maplibre/maplibre-react-native 11.0.0-alpha.33 → 11.0.0-alpha.34
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/MapLibreReactNative.podspec +1 -1
- package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +102 -90
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +271 -176
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt +66 -34
- package/android/src/main/java/org/maplibre/reactnative/http/RequestHeadersInterceptor.kt +65 -0
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNNetworkModule.kt +67 -0
- package/ios/modules/network/MLRNNetworkHTTPHeaders.h +14 -0
- package/ios/modules/network/MLRNNetworkHTTPHeaders.m +97 -0
- package/ios/modules/network/MLRNNetworkModule.h +8 -0
- package/ios/modules/network/MLRNNetworkModule.mm +28 -0
- package/lib/commonjs/components/layers/BackgroundLayer.js +2 -9
- package/lib/commonjs/components/layers/BackgroundLayer.js.map +1 -1
- package/lib/commonjs/components/layers/CircleLayer.js +2 -9
- package/lib/commonjs/components/layers/CircleLayer.js.map +1 -1
- package/lib/commonjs/components/layers/FillExtrusionLayer.js +2 -9
- package/lib/commonjs/components/layers/FillExtrusionLayer.js.map +1 -1
- package/lib/commonjs/components/layers/FillLayer.js +2 -9
- package/lib/commonjs/components/layers/FillLayer.js.map +1 -1
- package/lib/commonjs/components/layers/HeatmapLayer.js +2 -9
- package/lib/commonjs/components/layers/HeatmapLayer.js.map +1 -1
- package/lib/commonjs/components/layers/LineLayer.js +2 -9
- package/lib/commonjs/components/layers/LineLayer.js.map +1 -1
- package/lib/commonjs/components/layers/RasterLayer.js +2 -9
- package/lib/commonjs/components/layers/RasterLayer.js.map +1 -1
- package/lib/commonjs/components/layers/SymbolLayer.js +2 -9
- package/lib/commonjs/components/layers/SymbolLayer.js.map +1 -1
- package/lib/commonjs/components/map-view/MapView.js +0 -4
- package/lib/commonjs/components/map-view/MapView.js.map +1 -1
- package/lib/commonjs/index.js +8 -43
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/network/NativeNetworkModule.js +9 -0
- package/lib/commonjs/modules/network/NativeNetworkModule.js.map +1 -0
- package/lib/commonjs/modules/network/NetworkManager.js +72 -0
- package/lib/commonjs/modules/network/NetworkManager.js.map +1 -0
- package/lib/commonjs/modules/snapshot/SnapshotManager.js +3 -5
- package/lib/commonjs/modules/snapshot/SnapshotManager.js.map +1 -1
- package/lib/commonjs/modules/snapshot/SnapshotOptions.js +1 -3
- package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +1 -1
- package/lib/module/components/layers/BackgroundLayer.js +3 -10
- package/lib/module/components/layers/BackgroundLayer.js.map +1 -1
- package/lib/module/components/layers/CircleLayer.js +3 -10
- package/lib/module/components/layers/CircleLayer.js.map +1 -1
- package/lib/module/components/layers/FillExtrusionLayer.js +3 -10
- package/lib/module/components/layers/FillExtrusionLayer.js.map +1 -1
- package/lib/module/components/layers/FillLayer.js +3 -10
- package/lib/module/components/layers/FillLayer.js.map +1 -1
- package/lib/module/components/layers/HeatmapLayer.js +3 -10
- package/lib/module/components/layers/HeatmapLayer.js.map +1 -1
- package/lib/module/components/layers/LineLayer.js +3 -10
- package/lib/module/components/layers/LineLayer.js.map +1 -1
- package/lib/module/components/layers/RasterLayer.js +3 -10
- package/lib/module/components/layers/RasterLayer.js.map +1 -1
- package/lib/module/components/layers/SymbolLayer.js +3 -10
- package/lib/module/components/layers/SymbolLayer.js.map +1 -1
- package/lib/module/components/map-view/MapView.js +1 -5
- package/lib/module/components/map-view/MapView.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/network/NativeNetworkModule.js +5 -0
- package/lib/module/modules/network/NativeNetworkModule.js.map +1 -0
- package/lib/module/modules/network/NetworkManager.js +68 -0
- package/lib/module/modules/network/NetworkManager.js.map +1 -0
- package/lib/module/modules/snapshot/SnapshotManager.js +3 -5
- package/lib/module/modules/snapshot/SnapshotManager.js.map +1 -1
- package/lib/module/modules/snapshot/SnapshotOptions.js +1 -3
- package/lib/module/modules/snapshot/SnapshotOptions.js.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/BackgroundLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/BackgroundLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/CircleLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/CircleLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/FillExtrusionLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/FillLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/FillLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/HeatmapLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/HeatmapLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/LineLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/LineLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/RasterLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/RasterLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/SymbolLayer.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/layers/SymbolLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/network/NativeNetworkModule.d.ts +9 -0
- package/lib/typescript/commonjs/src/modules/network/NativeNetworkModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/network/NetworkManager.d.ts +56 -0
- package/lib/typescript/commonjs/src/modules/network/NetworkManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotManager.d.ts +2 -3
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts +2 -1
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +7 -7
- package/lib/typescript/module/src/components/layers/BackgroundLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/BackgroundLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/CircleLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/CircleLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/FillExtrusionLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/FillLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/FillLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/HeatmapLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/HeatmapLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/LineLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/LineLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/RasterLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/RasterLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/SymbolLayer.d.ts +1 -1
- package/lib/typescript/module/src/components/layers/SymbolLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/network/NativeNetworkModule.d.ts +9 -0
- package/lib/typescript/module/src/modules/network/NativeNetworkModule.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/network/NetworkManager.d.ts +56 -0
- package/lib/typescript/module/src/modules/network/NetworkManager.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/snapshot/SnapshotManager.d.ts +2 -3
- package/lib/typescript/module/src/modules/snapshot/SnapshotManager.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts +2 -1
- package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/Animated.d.ts +7 -7
- package/package.json +2 -2
- package/src/components/layers/BackgroundLayer.tsx +3 -11
- package/src/components/layers/CircleLayer.tsx +3 -11
- package/src/components/layers/FillExtrusionLayer.tsx +3 -11
- package/src/components/layers/FillLayer.tsx +3 -11
- package/src/components/layers/HeatmapLayer.tsx +3 -11
- package/src/components/layers/LineLayer.tsx +3 -11
- package/src/components/layers/RasterLayer.tsx +3 -11
- package/src/components/layers/SymbolLayer.tsx +3 -11
- package/src/components/map-view/MapView.tsx +0 -8
- package/src/index.ts +4 -3
- package/src/modules/network/NativeNetworkModule.ts +12 -0
- package/src/modules/network/NetworkManager.ts +74 -0
- package/src/modules/snapshot/SnapshotManager.ts +3 -5
- package/src/modules/snapshot/SnapshotOptions.ts +3 -5
- package/android/src/main/java/org/maplibre/reactnative/http/CustomHeadersInterceptor.java +0 -38
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNModule.java +0 -112
- package/ios/modules/mlrn/MLRNCustomHeaders.h +0 -20
- package/ios/modules/mlrn/MLRNCustomHeaders.m +0 -98
- package/ios/modules/mlrn/MLRNModule.h +0 -5
- package/ios/modules/mlrn/MLRNModule.m +0 -45
- package/lib/commonjs/MLRNModule.js +0 -21
- package/lib/commonjs/MLRNModule.js.map +0 -1
- package/lib/module/MLRNModule.js +0 -12
- package/lib/module/MLRNModule.js.map +0 -1
- package/lib/typescript/commonjs/src/MLRNModule.d.ts +0 -6
- package/lib/typescript/commonjs/src/MLRNModule.d.ts.map +0 -1
- package/lib/typescript/module/src/MLRNModule.d.ts +0 -6
- package/lib/typescript/module/src/MLRNModule.d.ts.map +0 -1
- package/src/MLRNModule.ts +0 -28
|
@@ -62,31 +62,46 @@ import org.maplibre.reactnative.components.sources.MLRNPressableSource
|
|
|
62
62
|
import org.maplibre.reactnative.components.sources.MLRNSource
|
|
63
63
|
import org.maplibre.reactnative.events.MapChangeEvent
|
|
64
64
|
import org.maplibre.reactnative.events.MapPressEvent
|
|
65
|
-
import org.maplibre.reactnative.modules.MLRNModule
|
|
66
65
|
import org.maplibre.reactnative.utils.BitmapUtils
|
|
67
66
|
import org.maplibre.reactnative.utils.GeoJSONUtils
|
|
68
67
|
import kotlin.math.roundToInt
|
|
69
68
|
|
|
70
69
|
sealed class MapChild {
|
|
71
|
-
data class FeatureChild(
|
|
72
|
-
|
|
70
|
+
data class FeatureChild(
|
|
71
|
+
val feature: AbstractMapFeature,
|
|
72
|
+
) : MapChild()
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
data class ViewChild(
|
|
75
|
+
val view: View,
|
|
76
|
+
) : MapChild()
|
|
77
|
+
|
|
78
|
+
fun toView(): View? =
|
|
79
|
+
when (this) {
|
|
80
|
+
is FeatureChild -> feature
|
|
81
|
+
is ViewChild -> view
|
|
82
|
+
}
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
open class MLRNMapView(
|
|
81
|
-
context: Context,
|
|
86
|
+
context: Context,
|
|
87
|
+
options: MapLibreMapOptions?,
|
|
82
88
|
) : MapView(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
MapView.
|
|
89
|
+
context,
|
|
90
|
+
options,
|
|
91
|
+
),
|
|
92
|
+
OnMapReadyCallback,
|
|
93
|
+
MapLibreMap.OnMapClickListener,
|
|
94
|
+
MapLibreMap.OnMapLongClickListener,
|
|
95
|
+
MapView.OnCameraIsChangingListener,
|
|
96
|
+
MapView.OnCameraDidChangeListener,
|
|
97
|
+
MapView.OnWillStartLoadingMapListener,
|
|
98
|
+
MapView.OnDidFailLoadingMapListener,
|
|
99
|
+
MapView.OnDidFinishLoadingMapListener,
|
|
100
|
+
MapView.OnWillStartRenderingFrameListener,
|
|
101
|
+
MapView.OnWillStartRenderingMapListener,
|
|
102
|
+
MapView.OnDidFinishRenderingFrameListener,
|
|
103
|
+
MapView.OnDidFinishRenderingMapListener,
|
|
104
|
+
MapView.OnDidFinishLoadingStyleListener,
|
|
90
105
|
MapView.OnStyleImageMissingListener {
|
|
91
106
|
constructor(context: Context) : this(context, options = null)
|
|
92
107
|
|
|
@@ -95,7 +110,8 @@ open class MLRNMapView(
|
|
|
95
110
|
|
|
96
111
|
@Suppress("UNUSED_PARAMETER")
|
|
97
112
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : this(
|
|
98
|
-
context,
|
|
113
|
+
context,
|
|
114
|
+
options = null,
|
|
99
115
|
)
|
|
100
116
|
|
|
101
117
|
private val handler: Handler
|
|
@@ -139,7 +155,6 @@ open class MLRNMapView(
|
|
|
139
155
|
private var compassMargins: IntArray? = null
|
|
140
156
|
private var compassHiddenFacingNorth: Boolean? = null
|
|
141
157
|
|
|
142
|
-
|
|
143
158
|
private var symbolManager: SymbolManager? = null
|
|
144
159
|
|
|
145
160
|
private var activeMarkerID: Long = -1
|
|
@@ -182,40 +197,45 @@ open class MLRNMapView(
|
|
|
182
197
|
destroyed = true
|
|
183
198
|
}
|
|
184
199
|
|
|
185
|
-
fun addFeature(
|
|
186
|
-
|
|
200
|
+
fun addFeature(
|
|
201
|
+
childView: View?,
|
|
202
|
+
childPosition: Int,
|
|
203
|
+
) {
|
|
204
|
+
val child: MapChild? =
|
|
205
|
+
when (childView) {
|
|
206
|
+
is MLRNCamera -> {
|
|
207
|
+
camera = childView
|
|
208
|
+
MapChild.FeatureChild(childView)
|
|
209
|
+
}
|
|
187
210
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
211
|
+
is MLRNSource<*> -> {
|
|
212
|
+
sources[childView.getID()] = childView
|
|
213
|
+
MapChild.FeatureChild(childView)
|
|
214
|
+
}
|
|
192
215
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
216
|
+
is MLRNPointAnnotation -> {
|
|
217
|
+
pointAnnotations[childView.getID()] = childView
|
|
218
|
+
MapChild.FeatureChild(childView)
|
|
219
|
+
}
|
|
197
220
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
221
|
+
is MLRNImages -> {
|
|
222
|
+
images.add(childView)
|
|
223
|
+
MapChild.FeatureChild(childView)
|
|
224
|
+
}
|
|
202
225
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
226
|
+
is MLRNNativeUserLocation, is MLRNMarkerView, is MLRNLayer<*> -> {
|
|
227
|
+
MapChild.FeatureChild(childView)
|
|
228
|
+
}
|
|
207
229
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
230
|
+
is ViewGroup -> {
|
|
231
|
+
MapChild.ViewChild(childView)
|
|
232
|
+
}
|
|
211
233
|
|
|
212
|
-
|
|
213
|
-
|
|
234
|
+
else -> {
|
|
235
|
+
null
|
|
236
|
+
}
|
|
214
237
|
}
|
|
215
238
|
|
|
216
|
-
else -> null
|
|
217
|
-
}
|
|
218
|
-
|
|
219
239
|
if (child != null) {
|
|
220
240
|
if (queuedChildren == null) {
|
|
221
241
|
when (child) {
|
|
@@ -273,9 +293,7 @@ open class MLRNMapView(
|
|
|
273
293
|
|
|
274
294
|
val featureCount: Int get() = children().size
|
|
275
295
|
|
|
276
|
-
fun getFeatureAt(i: Int): MapChild
|
|
277
|
-
return children()[i]
|
|
278
|
-
}
|
|
296
|
+
fun getFeatureAt(i: Int): MapChild = children()[i]
|
|
279
297
|
|
|
280
298
|
@Synchronized
|
|
281
299
|
fun dispose() {
|
|
@@ -301,7 +319,10 @@ open class MLRNMapView(
|
|
|
301
319
|
val cameraPosition: CameraPosition
|
|
302
320
|
get() = mapLibreMap!!.cameraPosition
|
|
303
321
|
|
|
304
|
-
fun moveCamera(
|
|
322
|
+
fun moveCamera(
|
|
323
|
+
cameraUpdate: CameraUpdate,
|
|
324
|
+
callback: MapLibreMap.CancelableCallback?,
|
|
325
|
+
) {
|
|
305
326
|
mapLibreMap!!.moveCamera(cameraUpdate, callback)
|
|
306
327
|
}
|
|
307
328
|
|
|
@@ -317,9 +338,7 @@ open class MLRNMapView(
|
|
|
317
338
|
return null
|
|
318
339
|
}
|
|
319
340
|
|
|
320
|
-
fun getSymbolManager(): SymbolManager
|
|
321
|
-
return symbolManager!!
|
|
322
|
-
}
|
|
341
|
+
fun getSymbolManager(): SymbolManager = symbolManager!!
|
|
323
342
|
|
|
324
343
|
interface FoundLayerCallback {
|
|
325
344
|
fun found(layer: Layer?)
|
|
@@ -342,7 +361,7 @@ open class MLRNMapView(
|
|
|
342
361
|
|
|
343
362
|
handler = Handler(Looper.getMainLooper())
|
|
344
363
|
|
|
345
|
-
mapStyle =
|
|
364
|
+
mapStyle = "https://demotiles.maplibre.org/style.json"
|
|
346
365
|
|
|
347
366
|
setLifecycleListeners()
|
|
348
367
|
|
|
@@ -371,7 +390,10 @@ open class MLRNMapView(
|
|
|
371
390
|
layerWaiters.remove(layerId)
|
|
372
391
|
}
|
|
373
392
|
|
|
374
|
-
fun waitForLayer(
|
|
393
|
+
fun waitForLayer(
|
|
394
|
+
layerID: String,
|
|
395
|
+
callback: FoundLayerCallback,
|
|
396
|
+
) {
|
|
375
397
|
val layer = mapLibreMap!!.style!!.getLayer(layerID)
|
|
376
398
|
if (layer != null) {
|
|
377
399
|
callback.found(layer)
|
|
@@ -422,20 +444,22 @@ open class MLRNMapView(
|
|
|
422
444
|
}
|
|
423
445
|
}
|
|
424
446
|
|
|
425
|
-
mapLibreMap.addOnMoveListener(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
447
|
+
mapLibreMap.addOnMoveListener(
|
|
448
|
+
object : MapLibreMap.OnMoveListener {
|
|
449
|
+
override fun onMoveBegin(detector: MoveGestureDetector) {
|
|
450
|
+
cameraChangeTracker.setReason(CameraChangeTracker.USER_GESTURE)
|
|
451
|
+
handleMapChangedEvent("onRegionWillChange", true)
|
|
452
|
+
}
|
|
430
453
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
454
|
+
override fun onMove(detector: MoveGestureDetector) {
|
|
455
|
+
cameraChangeTracker.setReason(CameraChangeTracker.USER_GESTURE)
|
|
456
|
+
handleMapChangedEvent("onRegionIsChanging", true)
|
|
457
|
+
}
|
|
435
458
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
459
|
+
override fun onMoveEnd(detector: MoveGestureDetector) {
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
)
|
|
439
463
|
|
|
440
464
|
mapLibreMap.addOnCameraIdleListener { sendRegionDidChangeEvent() }
|
|
441
465
|
}
|
|
@@ -444,7 +468,7 @@ open class MLRNMapView(
|
|
|
444
468
|
handler.post {
|
|
445
469
|
measure(
|
|
446
470
|
MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
|
|
447
|
-
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY)
|
|
471
|
+
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY),
|
|
448
472
|
)
|
|
449
473
|
layout(left, top, right, bottom)
|
|
450
474
|
}
|
|
@@ -457,27 +481,29 @@ open class MLRNMapView(
|
|
|
457
481
|
onMarkerClick(symbol)
|
|
458
482
|
true
|
|
459
483
|
}
|
|
460
|
-
symbolManager!!.addDragListener(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
484
|
+
symbolManager!!.addDragListener(
|
|
485
|
+
object : OnSymbolDragListener {
|
|
486
|
+
override fun onAnnotationDragStarted(symbol: Symbol) {
|
|
487
|
+
annotationClicked = true
|
|
488
|
+
val selectedMarkerID = symbol.id
|
|
489
|
+
val annotation = getPointAnnotationByMarkerID(selectedMarkerID)
|
|
490
|
+
annotation?.onDragStart()
|
|
491
|
+
}
|
|
467
492
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
493
|
+
override fun onAnnotationDrag(symbol: Symbol) {
|
|
494
|
+
val selectedMarkerID = symbol.id
|
|
495
|
+
val annotation = getPointAnnotationByMarkerID(selectedMarkerID)
|
|
496
|
+
annotation?.onDrag()
|
|
497
|
+
}
|
|
473
498
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
499
|
+
override fun onAnnotationDragFinished(symbol: Symbol) {
|
|
500
|
+
annotationClicked = false
|
|
501
|
+
val selectedMarkerID = symbol.id
|
|
502
|
+
val annotation = getPointAnnotationByMarkerID(selectedMarkerID)
|
|
503
|
+
annotation?.onDragEnd()
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
)
|
|
481
507
|
mapLibreMap!!.addOnMapClickListener(this)
|
|
482
508
|
mapLibreMap!!.addOnMapLongClickListener(this)
|
|
483
509
|
}
|
|
@@ -515,7 +541,13 @@ open class MLRNMapView(
|
|
|
515
541
|
return result
|
|
516
542
|
}
|
|
517
543
|
|
|
518
|
-
override fun onLayout(
|
|
544
|
+
override fun onLayout(
|
|
545
|
+
changed: Boolean,
|
|
546
|
+
left: Int,
|
|
547
|
+
top: Int,
|
|
548
|
+
right: Int,
|
|
549
|
+
bottom: Int,
|
|
550
|
+
) {
|
|
519
551
|
if (!paused) {
|
|
520
552
|
if (markerViewManager != null) {
|
|
521
553
|
markerViewManager!!.removeViews()
|
|
@@ -527,7 +559,6 @@ open class MLRNMapView(
|
|
|
527
559
|
}
|
|
528
560
|
}
|
|
529
561
|
|
|
530
|
-
|
|
531
562
|
override fun onMapClick(latLng: LatLng): Boolean {
|
|
532
563
|
if (annotationClicked) {
|
|
533
564
|
annotationClicked = false
|
|
@@ -541,13 +572,13 @@ open class MLRNMapView(
|
|
|
541
572
|
for (pressableSource in this.pressableSources) {
|
|
542
573
|
val hitbox = pressableSource.hitbox ?: continue
|
|
543
574
|
|
|
544
|
-
val pointWithHitbox =
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
575
|
+
val pointWithHitbox =
|
|
576
|
+
RectF(
|
|
577
|
+
screenPoint.x - hitbox.left,
|
|
578
|
+
screenPoint.y - hitbox.top,
|
|
579
|
+
screenPoint.x + hitbox.right,
|
|
580
|
+
screenPoint.y + hitbox.bottom,
|
|
581
|
+
)
|
|
551
582
|
|
|
552
583
|
val features =
|
|
553
584
|
mapLibreMap!!.queryRenderedFeatures(pointWithHitbox, *pressableSource.getLayerIDs())
|
|
@@ -644,13 +675,14 @@ open class MLRNMapView(
|
|
|
644
675
|
handleMapChangedEvent("onDidFailLoadingMap")
|
|
645
676
|
}
|
|
646
677
|
|
|
647
|
-
|
|
648
678
|
override fun onWillStartRenderingFrame() {
|
|
649
679
|
handleMapChangedEvent("onWillStartRenderingFrame")
|
|
650
680
|
}
|
|
651
681
|
|
|
652
682
|
override fun onDidFinishRenderingFrame(
|
|
653
|
-
fully: Boolean,
|
|
683
|
+
fully: Boolean,
|
|
684
|
+
frameEncodingTime: Double,
|
|
685
|
+
frameRenderingTime: Double,
|
|
654
686
|
) {
|
|
655
687
|
if (fully) {
|
|
656
688
|
handleMapChangedEvent("onDidFinishRenderingFrameFully")
|
|
@@ -699,7 +731,7 @@ open class MLRNMapView(
|
|
|
699
731
|
|
|
700
732
|
if (isJSONValid(mapStyle)) {
|
|
701
733
|
mapLibreMap!!.setStyle(
|
|
702
|
-
Style.Builder().fromJson(mapStyle)
|
|
734
|
+
Style.Builder().fromJson(mapStyle),
|
|
703
735
|
) {
|
|
704
736
|
addAllSourcesToMap()
|
|
705
737
|
}
|
|
@@ -782,7 +814,7 @@ open class MLRNMapView(
|
|
|
782
814
|
defaultGravityKey: (MapLibreMapOptions) -> Int,
|
|
783
815
|
defaultMarginsKey: (MapLibreMapOptions) -> IntArray,
|
|
784
816
|
setGravity: (Int) -> Unit,
|
|
785
|
-
setMargins: (IntArray) -> Unit
|
|
817
|
+
setMargins: (IntArray) -> Unit,
|
|
786
818
|
) {
|
|
787
819
|
if (position == null) {
|
|
788
820
|
val defaults = MapLibreMapOptions.createFromAttributes(context)
|
|
@@ -795,12 +827,13 @@ open class MLRNMapView(
|
|
|
795
827
|
if (position.hasKey("top")) gravity = gravity or Gravity.TOP
|
|
796
828
|
if (position.hasKey("bottom")) gravity = gravity or Gravity.BOTTOM
|
|
797
829
|
val density = this.displayDensity
|
|
798
|
-
val margins =
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
830
|
+
val margins =
|
|
831
|
+
intArrayOf(
|
|
832
|
+
if (position.hasKey("left")) (density * position.getInt("left")).roundToInt() else 0,
|
|
833
|
+
if (position.hasKey("top")) (density * position.getInt("top")).roundToInt() else 0,
|
|
834
|
+
if (position.hasKey("right")) (density * position.getInt("right")).roundToInt() else 0,
|
|
835
|
+
if (position.hasKey("bottom")) (density * position.getInt("bottom")).roundToInt() else 0,
|
|
836
|
+
)
|
|
804
837
|
setGravity(gravity)
|
|
805
838
|
setMargins(margins)
|
|
806
839
|
}
|
|
@@ -818,7 +851,8 @@ open class MLRNMapView(
|
|
|
818
851
|
{ it.attributionGravity },
|
|
819
852
|
{ it.attributionMargins },
|
|
820
853
|
{ attributionGravity = it },
|
|
821
|
-
{ attributionMargin = it }
|
|
854
|
+
{ attributionMargin = it },
|
|
855
|
+
)
|
|
822
856
|
}
|
|
823
857
|
|
|
824
858
|
fun setReactLogo(value: Boolean) {
|
|
@@ -832,7 +866,8 @@ open class MLRNMapView(
|
|
|
832
866
|
{ it.logoGravity },
|
|
833
867
|
{ it.logoMargins },
|
|
834
868
|
{ logoGravity = it },
|
|
835
|
-
{ logoMargins = it }
|
|
869
|
+
{ logoMargins = it },
|
|
870
|
+
)
|
|
836
871
|
}
|
|
837
872
|
|
|
838
873
|
fun setReactCompass(value: Boolean) {
|
|
@@ -846,7 +881,8 @@ open class MLRNMapView(
|
|
|
846
881
|
{ it.compassGravity },
|
|
847
882
|
{ it.compassMargins },
|
|
848
883
|
{ compassGravity = it },
|
|
849
|
-
{ compassMargins = it }
|
|
884
|
+
{ compassMargins = it },
|
|
885
|
+
)
|
|
850
886
|
}
|
|
851
887
|
|
|
852
888
|
fun setReactCompassHiddenFacingNorth(value: Boolean) {
|
|
@@ -897,40 +933,48 @@ open class MLRNMapView(
|
|
|
897
933
|
}
|
|
898
934
|
|
|
899
935
|
fun queryRenderedFeaturesWithPoint(
|
|
900
|
-
point: PointF,
|
|
936
|
+
point: PointF,
|
|
937
|
+
layers: ReadableArray?,
|
|
938
|
+
filter: Expression?,
|
|
901
939
|
): WritableArray {
|
|
902
940
|
val density = this.displayDensity
|
|
903
941
|
val screenPoint = PointF(point.x * density, point.y * density)
|
|
904
942
|
|
|
905
|
-
val features =
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
943
|
+
val features =
|
|
944
|
+
mapLibreMap!!.queryRenderedFeatures(
|
|
945
|
+
screenPoint,
|
|
946
|
+
filter,
|
|
947
|
+
*(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()),
|
|
948
|
+
)
|
|
909
949
|
|
|
910
950
|
return GeoJSONUtils.fromFeatureList(features)
|
|
911
951
|
}
|
|
912
952
|
|
|
913
|
-
|
|
914
953
|
fun queryRenderedFeaturesWithRect(
|
|
915
|
-
rect: RectF?,
|
|
954
|
+
rect: RectF?,
|
|
955
|
+
layers: ReadableArray?,
|
|
956
|
+
filter: Expression?,
|
|
916
957
|
): WritableArray {
|
|
917
|
-
val screenRect =
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
958
|
+
val screenRect =
|
|
959
|
+
if (rect == null) {
|
|
960
|
+
val width = this.width.toFloat()
|
|
961
|
+
val height = this.height.toFloat()
|
|
962
|
+
RectF(0f, 0f, width, height)
|
|
963
|
+
} else {
|
|
964
|
+
RectF(
|
|
965
|
+
rect.left * this.displayDensity,
|
|
966
|
+
rect.top * this.displayDensity,
|
|
967
|
+
rect.right * this.displayDensity,
|
|
968
|
+
rect.bottom * this.displayDensity,
|
|
969
|
+
)
|
|
970
|
+
}
|
|
929
971
|
|
|
930
|
-
val features =
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
972
|
+
val features =
|
|
973
|
+
mapLibreMap!!.queryRenderedFeatures(
|
|
974
|
+
screenRect,
|
|
975
|
+
filter,
|
|
976
|
+
*(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()),
|
|
977
|
+
)
|
|
934
978
|
|
|
935
979
|
return GeoJSONUtils.fromFeatureList(features)
|
|
936
980
|
}
|
|
@@ -958,14 +1002,21 @@ open class MLRNMapView(
|
|
|
958
1002
|
return GeoJSONUtils.fromLatLng(latLng)
|
|
959
1003
|
}
|
|
960
1004
|
|
|
961
|
-
fun takeSnap(
|
|
1005
|
+
fun takeSnap(
|
|
1006
|
+
writeToDisk: Boolean,
|
|
1007
|
+
callback: (String) -> Unit,
|
|
1008
|
+
) {
|
|
962
1009
|
if (this.mapLibreMap == null) {
|
|
963
1010
|
throw Error("takeSnap should only be called after the map has rendered")
|
|
964
1011
|
}
|
|
965
1012
|
|
|
966
1013
|
mapLibreMap!!.snapshot { snapshot ->
|
|
967
|
-
val uri =
|
|
968
|
-
|
|
1014
|
+
val uri =
|
|
1015
|
+
if (writeToDisk) {
|
|
1016
|
+
BitmapUtils.createTempFile(context, snapshot)
|
|
1017
|
+
} else {
|
|
1018
|
+
BitmapUtils.createBase64(snapshot)
|
|
1019
|
+
}
|
|
969
1020
|
|
|
970
1021
|
callback(uri)
|
|
971
1022
|
}
|
|
@@ -977,7 +1028,9 @@ open class MLRNMapView(
|
|
|
977
1028
|
}
|
|
978
1029
|
|
|
979
1030
|
fun setSourceVisibility(
|
|
980
|
-
visible: Boolean,
|
|
1031
|
+
visible: Boolean,
|
|
1032
|
+
sourceId: String,
|
|
1033
|
+
sourceLayerId: String?,
|
|
981
1034
|
) {
|
|
982
1035
|
if (this.mapLibreMap == null) {
|
|
983
1036
|
return
|
|
@@ -998,9 +1051,7 @@ open class MLRNMapView(
|
|
|
998
1051
|
viewTreeObserver.dispatchOnGlobalLayout()
|
|
999
1052
|
}
|
|
1000
1053
|
|
|
1001
|
-
override fun isDestroyed(): Boolean
|
|
1002
|
-
return destroyed
|
|
1003
|
-
}
|
|
1054
|
+
override fun isDestroyed(): Boolean = destroyed
|
|
1004
1055
|
|
|
1005
1056
|
fun getStyle(onStyleLoaded: OnStyleLoaded) {
|
|
1006
1057
|
if (this.mapLibreMap == null) {
|
|
@@ -1057,12 +1108,18 @@ open class MLRNMapView(
|
|
|
1057
1108
|
uiSettings.attributionGravity = attributionGravity!!
|
|
1058
1109
|
}
|
|
1059
1110
|
|
|
1060
|
-
if (attributionMargin != null &&
|
|
1111
|
+
if (attributionMargin != null &&
|
|
1112
|
+
(
|
|
1113
|
+
uiSettings.attributionMarginLeft != attributionMargin!![0] || uiSettings.attributionMarginTop != attributionMargin!![1] ||
|
|
1114
|
+
uiSettings.attributionMarginRight != attributionMargin!![2] ||
|
|
1115
|
+
uiSettings.attributionMarginBottom != attributionMargin!![3]
|
|
1116
|
+
)
|
|
1117
|
+
) {
|
|
1061
1118
|
uiSettings.setAttributionMargins(
|
|
1062
1119
|
attributionMargin!![0],
|
|
1063
1120
|
attributionMargin!![1],
|
|
1064
1121
|
attributionMargin!![2],
|
|
1065
|
-
attributionMargin!![3]
|
|
1122
|
+
attributionMargin!![3],
|
|
1066
1123
|
)
|
|
1067
1124
|
}
|
|
1068
1125
|
|
|
@@ -1074,9 +1131,18 @@ open class MLRNMapView(
|
|
|
1074
1131
|
uiSettings.logoGravity = logoGravity!!
|
|
1075
1132
|
}
|
|
1076
1133
|
|
|
1077
|
-
if (logoMargins != null &&
|
|
1134
|
+
if (logoMargins != null &&
|
|
1135
|
+
(
|
|
1136
|
+
uiSettings.logoMarginLeft != logoMargins!![0] || uiSettings.logoMarginTop != logoMargins!![1] ||
|
|
1137
|
+
uiSettings.logoMarginRight != logoMargins!![2] ||
|
|
1138
|
+
uiSettings.logoMarginBottom != logoMargins!![3]
|
|
1139
|
+
)
|
|
1140
|
+
) {
|
|
1078
1141
|
uiSettings.setLogoMargins(
|
|
1079
|
-
logoMargins!![0],
|
|
1142
|
+
logoMargins!![0],
|
|
1143
|
+
logoMargins!![1],
|
|
1144
|
+
logoMargins!![2],
|
|
1145
|
+
logoMargins!![3],
|
|
1080
1146
|
)
|
|
1081
1147
|
}
|
|
1082
1148
|
|
|
@@ -1088,9 +1154,18 @@ open class MLRNMapView(
|
|
|
1088
1154
|
uiSettings.compassGravity = compassGravity!!
|
|
1089
1155
|
}
|
|
1090
1156
|
|
|
1091
|
-
if (compassMargins != null &&
|
|
1157
|
+
if (compassMargins != null &&
|
|
1158
|
+
(
|
|
1159
|
+
uiSettings.compassMarginLeft != compassMargins!![0] || uiSettings.compassMarginTop != compassMargins!![1] ||
|
|
1160
|
+
uiSettings.compassMarginRight != compassMargins!![2] ||
|
|
1161
|
+
uiSettings.compassMarginBottom != compassMargins!![3]
|
|
1162
|
+
)
|
|
1163
|
+
) {
|
|
1092
1164
|
uiSettings.setCompassMargins(
|
|
1093
|
-
compassMargins!![0],
|
|
1165
|
+
compassMargins!![0],
|
|
1166
|
+
compassMargins!![1],
|
|
1167
|
+
compassMargins!![2],
|
|
1168
|
+
compassMargins!![3],
|
|
1094
1169
|
)
|
|
1095
1170
|
}
|
|
1096
1171
|
if (compassHiddenFacingNorth != null) {
|
|
@@ -1132,12 +1207,11 @@ open class MLRNMapView(
|
|
|
1132
1207
|
left = top
|
|
1133
1208
|
}
|
|
1134
1209
|
|
|
1135
|
-
|
|
1136
1210
|
return doubleArrayOf(
|
|
1137
1211
|
left * displayDensity,
|
|
1138
1212
|
top * displayDensity,
|
|
1139
1213
|
right * displayDensity,
|
|
1140
|
-
bottom * displayDensity
|
|
1214
|
+
bottom * displayDensity,
|
|
1141
1215
|
)
|
|
1142
1216
|
}
|
|
1143
1217
|
|
|
@@ -1153,26 +1227,30 @@ open class MLRNMapView(
|
|
|
1153
1227
|
val left = padding[0]
|
|
1154
1228
|
|
|
1155
1229
|
mapLibreMap!!.setPadding(
|
|
1156
|
-
left.toInt(),
|
|
1230
|
+
left.toInt(),
|
|
1231
|
+
top.toInt(),
|
|
1232
|
+
right.toInt(),
|
|
1233
|
+
bottom.toInt(),
|
|
1157
1234
|
)
|
|
1158
1235
|
}
|
|
1159
1236
|
|
|
1160
1237
|
private fun setLifecycleListeners() {
|
|
1161
1238
|
val reactContext = context as ReactContext
|
|
1162
1239
|
|
|
1163
|
-
lifeCycleListener =
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1240
|
+
lifeCycleListener =
|
|
1241
|
+
object : LifecycleEventListener {
|
|
1242
|
+
override fun onHostResume() {
|
|
1243
|
+
onResume()
|
|
1244
|
+
}
|
|
1167
1245
|
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1246
|
+
override fun onHostPause() {
|
|
1247
|
+
onPause()
|
|
1248
|
+
}
|
|
1171
1249
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1250
|
+
override fun onHostDestroy() {
|
|
1251
|
+
dispose()
|
|
1252
|
+
}
|
|
1174
1253
|
}
|
|
1175
|
-
}
|
|
1176
1254
|
|
|
1177
1255
|
reactContext.addLifecycleEventListener(lifeCycleListener)
|
|
1178
1256
|
}
|
|
@@ -1185,10 +1263,13 @@ open class MLRNMapView(
|
|
|
1185
1263
|
return viewState
|
|
1186
1264
|
}
|
|
1187
1265
|
|
|
1188
|
-
viewState.putArray(
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1266
|
+
viewState.putArray(
|
|
1267
|
+
"center",
|
|
1268
|
+
Arguments.createArray().apply {
|
|
1269
|
+
pushDouble(position.target!!.longitude)
|
|
1270
|
+
pushDouble(position.target!!.latitude)
|
|
1271
|
+
},
|
|
1272
|
+
)
|
|
1192
1273
|
|
|
1193
1274
|
viewState.putDouble("zoom", position.zoom)
|
|
1194
1275
|
viewState.putDouble("bearing", position.bearing)
|
|
@@ -1197,18 +1278,22 @@ open class MLRNMapView(
|
|
|
1197
1278
|
try {
|
|
1198
1279
|
val visibleRegion = mapLibreMap!!.projection.visibleRegion
|
|
1199
1280
|
viewState.putArray(
|
|
1200
|
-
"bounds",
|
|
1281
|
+
"bounds",
|
|
1282
|
+
GeoJSONUtils.fromLatLngBounds(visibleRegion.latLngBounds),
|
|
1201
1283
|
)
|
|
1202
1284
|
} catch (ex: Exception) {
|
|
1203
1285
|
Logger.e(
|
|
1204
|
-
LOG_TAG,
|
|
1205
|
-
|
|
1206
|
-
|
|
1286
|
+
LOG_TAG,
|
|
1287
|
+
String.format(
|
|
1288
|
+
"An error occurred while attempting to make the region: %s",
|
|
1289
|
+
ex.message,
|
|
1290
|
+
),
|
|
1207
1291
|
)
|
|
1208
1292
|
}
|
|
1209
1293
|
|
|
1210
1294
|
viewState.putBoolean(
|
|
1211
|
-
"animated",
|
|
1295
|
+
"animated",
|
|
1296
|
+
isAnimated ?: cameraChangeTracker.isAnimated,
|
|
1212
1297
|
)
|
|
1213
1298
|
viewState.putBoolean("userInteraction", cameraChangeTracker.isUserInteraction)
|
|
1214
1299
|
|
|
@@ -1216,9 +1301,13 @@ open class MLRNMapView(
|
|
|
1216
1301
|
}
|
|
1217
1302
|
|
|
1218
1303
|
fun sendRegionChangeEvent(isAnimated: Boolean) {
|
|
1219
|
-
val event =
|
|
1220
|
-
|
|
1221
|
-
|
|
1304
|
+
val event =
|
|
1305
|
+
MapChangeEvent(
|
|
1306
|
+
surfaceId,
|
|
1307
|
+
id,
|
|
1308
|
+
"onRegionDidChange",
|
|
1309
|
+
makeViewState(isAnimated),
|
|
1310
|
+
)
|
|
1222
1311
|
eventDispatcher?.dispatchEvent(event)
|
|
1223
1312
|
|
|
1224
1313
|
cameraChangeTracker.setReason(CameraChangeTracker.EMPTY)
|
|
@@ -1293,12 +1382,16 @@ open class MLRNMapView(
|
|
|
1293
1382
|
cameraChangeTracker.setReason(CameraChangeTracker.EMPTY)
|
|
1294
1383
|
}
|
|
1295
1384
|
|
|
1296
|
-
private fun handleMapChangedEvent(
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1385
|
+
private fun handleMapChangedEvent(
|
|
1386
|
+
eventName: String,
|
|
1387
|
+
withViewState: Boolean? = null,
|
|
1388
|
+
) {
|
|
1389
|
+
val event =
|
|
1390
|
+
if (withViewState == true) {
|
|
1391
|
+
MapChangeEvent(surfaceId, id, eventName, makeViewState(null))
|
|
1392
|
+
} else {
|
|
1393
|
+
MapChangeEvent(surfaceId, id, eventName)
|
|
1394
|
+
}
|
|
1302
1395
|
|
|
1303
1396
|
eventDispatcher?.dispatchEvent(event)
|
|
1304
1397
|
}
|
|
@@ -1308,9 +1401,11 @@ open class MLRNMapView(
|
|
|
1308
1401
|
*/
|
|
1309
1402
|
private fun setUpImage(loadedStyle: Style) {
|
|
1310
1403
|
loadedStyle.addImage(
|
|
1311
|
-
"MARKER_IMAGE_ID",
|
|
1312
|
-
|
|
1313
|
-
|
|
1404
|
+
"MARKER_IMAGE_ID",
|
|
1405
|
+
BitmapFactory.decodeResource(
|
|
1406
|
+
this.resources,
|
|
1407
|
+
R.drawable.red_marker,
|
|
1408
|
+
),
|
|
1314
1409
|
)
|
|
1315
1410
|
}
|
|
1316
1411
|
|