@maplibre/maplibre-react-native 11.0.0-alpha.35 → 11.0.0-alpha.37
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/java/org/maplibre/reactnative/MLRNPackage.kt +13 -13
- package/android/src/main/java/org/maplibre/reactnative/components/images/MLRNImages.java +3 -3
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +3 -11
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt +3 -3
- package/android/src/main/java/org/maplibre/reactnative/components/sources/geojsonsource/ClusterPropertyEntry.kt +8 -0
- package/android/src/main/java/org/maplibre/reactnative/components/sources/{shapesource/MLRNShapeSource.kt → geojsonsource/MLRNGeoJSONSource.kt} +20 -16
- package/android/src/main/java/org/maplibre/reactnative/components/sources/{shapesource/MLRNShapeSourceManager.kt → geojsonsource/MLRNGeoJSONSourceManager.kt} +64 -35
- package/android/src/main/java/org/maplibre/reactnative/components/sources/{shapesource/MLRNShapeSourceModule.kt → geojsonsource/MLRNGeoJSONSourceModule.kt} +22 -13
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNStaticMapModule.kt +121 -0
- package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.kt +29 -7
- package/ios/components/images/MLRNImages.m +2 -2
- package/ios/components/map-view/MLRNMapView.m +18 -36
- package/ios/components/map-view/MLRNMapViewManager.h +1 -1
- package/ios/components/map-view/MLRNMapViewManager.m +2 -2
- package/ios/components/map-view/MLRNMapViewModule.mm +6 -6
- package/ios/components/sources/{shape-source/MLRNShapeSource.h → geojson-source/MLRNGeoJSONSource.h} +2 -1
- package/ios/components/sources/{shape-source/MLRNShapeSource.m → geojson-source/MLRNGeoJSONSource.m} +12 -2
- package/ios/components/sources/geojson-source/MLRNGeoJSONSourceComponentView.h +11 -0
- package/ios/components/sources/{shape-source/MLRNShapeSourceComponentView.mm → geojson-source/MLRNGeoJSONSourceComponentView.mm} +21 -19
- package/ios/components/sources/geojson-source/MLRNGeoJSONSourceModule.h +5 -0
- package/ios/components/sources/{shape-source/MLRNShapeSourceModule.mm → geojson-source/MLRNGeoJSONSourceModule.mm} +14 -14
- package/ios/modules/offline/MLRNOfflineModule.mm +0 -1
- package/ios/modules/static-map/MLRNStaticMapModule.h +4 -0
- package/ios/modules/static-map/MLRNStaticMapModule.mm +84 -0
- package/ios/utils/MLRNEventTypes.h +0 -7
- package/ios/utils/MLRNEventTypes.m +0 -7
- package/ios/utils/MLRNUtils.h +1 -0
- package/ios/utils/MLRNUtils.m +14 -0
- package/lib/commonjs/components/annotations/Annotation.js +1 -1
- package/lib/commonjs/components/annotations/Annotation.js.map +1 -1
- package/lib/commonjs/components/annotations/PointAnnotation.js +1 -1
- package/lib/commonjs/components/map-view/MapView.js +1 -1
- package/lib/commonjs/components/map-view/MapView.js.map +1 -1
- package/lib/commonjs/components/sources/{shape-source/ShapeSource.js → geojson-source/GeoJSONSource.js} +12 -12
- package/lib/commonjs/components/sources/geojson-source/GeoJSONSource.js.map +1 -0
- package/{src/components/sources/shape-source/ShapeSourceNativeComponent.ts → lib/commonjs/components/sources/geojson-source/GeoJSONSourceNativeComponent.ts} +1 -1
- package/lib/commonjs/components/sources/{shape-source/NativeShapeSourceModule.js → geojson-source/NativeGeoJSONSourceModule.js} +2 -2
- package/lib/commonjs/components/sources/geojson-source/NativeGeoJSONSourceModule.js.map +1 -0
- package/lib/commonjs/hooks/useFrozenId.js +2 -2
- package/lib/commonjs/hooks/useFrozenId.js.map +1 -1
- package/lib/commonjs/index.js +11 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/{snapshot/NativeSnapshotModule.js → static-map/NativeStaticMapModule.js} +2 -2
- package/lib/commonjs/modules/static-map/NativeStaticMapModule.js.map +1 -0
- package/lib/commonjs/modules/static-map/StaticMapManager.js +49 -0
- package/lib/commonjs/modules/static-map/StaticMapManager.js.map +1 -0
- package/lib/commonjs/utils/animated/Animated.js +4 -4
- package/lib/commonjs/utils/animated/Animated.js.map +1 -1
- package/lib/commonjs/utils/animated/{AnimatedShape.js → AnimatedGeoJSON.js} +18 -18
- package/lib/commonjs/utils/animated/AnimatedGeoJSON.js.map +1 -0
- package/lib/module/components/annotations/Annotation.js +1 -1
- package/lib/module/components/annotations/Annotation.js.map +1 -1
- package/lib/module/components/annotations/PointAnnotation.js +1 -1
- package/lib/module/components/map-view/MapView.js +1 -1
- package/lib/module/components/map-view/MapView.js.map +1 -1
- package/lib/module/components/sources/{shape-source/ShapeSource.js → geojson-source/GeoJSONSource.js} +11 -11
- package/lib/module/components/sources/geojson-source/GeoJSONSource.js.map +1 -0
- package/lib/{commonjs/components/sources/shape-source/ShapeSourceNativeComponent.ts → module/components/sources/geojson-source/GeoJSONSourceNativeComponent.ts} +1 -1
- package/lib/module/components/sources/geojson-source/NativeGeoJSONSourceModule.js +5 -0
- package/lib/module/components/sources/geojson-source/NativeGeoJSONSourceModule.js.map +1 -0
- package/lib/module/hooks/useFrozenId.js +2 -2
- package/lib/module/hooks/useFrozenId.js.map +1 -1
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/static-map/NativeStaticMapModule.js +5 -0
- package/lib/module/modules/static-map/NativeStaticMapModule.js.map +1 -0
- package/lib/module/modules/static-map/StaticMapManager.js +45 -0
- package/lib/module/modules/static-map/StaticMapManager.js.map +1 -0
- package/lib/module/utils/animated/Animated.js +4 -4
- package/lib/module/utils/animated/Animated.js.map +1 -1
- package/lib/module/utils/animated/{AnimatedShape.js → AnimatedGeoJSON.js} +16 -16
- package/lib/module/utils/animated/AnimatedGeoJSON.js.map +1 -0
- package/lib/typescript/commonjs/src/components/Images.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/annotations/PointAnnotation.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts +10 -6
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/sources/{shape-source/ShapeSource.d.ts → geojson-source/GeoJSONSource.d.ts} +16 -16
- package/lib/typescript/commonjs/src/components/sources/geojson-source/GeoJSONSource.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/sources/{shape-source/ShapeSourceNativeComponent.d.ts → geojson-source/GeoJSONSourceNativeComponent.d.ts} +1 -1
- package/lib/typescript/commonjs/src/components/sources/geojson-source/GeoJSONSourceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/sources/{shape-source/NativeShapeSourceModule.d.ts → geojson-source/NativeGeoJSONSourceModule.d.ts} +1 -1
- package/lib/typescript/commonjs/src/components/sources/geojson-source/NativeGeoJSONSourceModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -4
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/static-map/NativeStaticMapModule.d.ts +19 -0
- package/lib/typescript/commonjs/src/modules/static-map/NativeStaticMapModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/static-map/StaticMapManager.d.ts +97 -0
- package/lib/typescript/commonjs/src/modules/static-map/StaticMapManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +4 -4
- package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts.map +1 -1
- package/lib/typescript/{module/src/utils/animated/AnimatedShape.d.ts → commonjs/src/utils/animated/AnimatedGeoJSON.d.ts} +8 -8
- package/lib/typescript/commonjs/src/utils/animated/AnimatedGeoJSON.d.ts.map +1 -0
- package/lib/typescript/module/src/components/Images.d.ts +1 -1
- package/lib/typescript/module/src/components/annotations/PointAnnotation.d.ts +1 -1
- package/lib/typescript/module/src/components/map-view/MapView.d.ts +10 -6
- package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts +1 -1
- package/lib/typescript/module/src/components/map-view/NativeMapViewModule.d.ts.map +1 -1
- package/lib/typescript/module/src/components/sources/{shape-source/ShapeSource.d.ts → geojson-source/GeoJSONSource.d.ts} +16 -16
- package/lib/typescript/module/src/components/sources/geojson-source/GeoJSONSource.d.ts.map +1 -0
- package/lib/typescript/module/src/components/sources/{shape-source/ShapeSourceNativeComponent.d.ts → geojson-source/GeoJSONSourceNativeComponent.d.ts} +1 -1
- package/lib/typescript/module/src/components/sources/geojson-source/GeoJSONSourceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/components/sources/{shape-source/NativeShapeSourceModule.d.ts → geojson-source/NativeGeoJSONSourceModule.d.ts} +1 -1
- package/lib/typescript/module/src/components/sources/geojson-source/NativeGeoJSONSourceModule.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -4
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/static-map/NativeStaticMapModule.d.ts +19 -0
- package/lib/typescript/module/src/modules/static-map/NativeStaticMapModule.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/static-map/StaticMapManager.d.ts +97 -0
- package/lib/typescript/module/src/modules/static-map/StaticMapManager.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/animated/Animated.d.ts +4 -4
- package/lib/typescript/module/src/utils/animated/Animated.d.ts.map +1 -1
- package/lib/typescript/{commonjs/src/utils/animated/AnimatedShape.d.ts → module/src/utils/animated/AnimatedGeoJSON.d.ts} +8 -8
- package/lib/typescript/module/src/utils/animated/AnimatedGeoJSON.d.ts.map +1 -0
- package/package.json +5 -4
- package/src/components/Images.tsx +1 -1
- package/src/components/annotations/Annotation.tsx +2 -2
- package/src/components/annotations/PointAnnotation.tsx +1 -1
- package/src/components/map-view/MapView.tsx +11 -9
- package/src/components/map-view/NativeMapViewModule.ts +2 -2
- package/src/components/sources/{shape-source/ShapeSource.tsx → geojson-source/GeoJSONSource.tsx} +25 -25
- package/{lib/module/components/sources/shape-source/ShapeSourceNativeComponent.ts → src/components/sources/geojson-source/GeoJSONSourceNativeComponent.ts} +1 -1
- package/src/components/sources/{shape-source/NativeShapeSourceModule.ts → geojson-source/NativeGeoJSONSourceModule.ts} +3 -1
- package/src/hooks/useFrozenId.ts +2 -2
- package/src/index.ts +13 -8
- package/src/modules/static-map/NativeStaticMapModule.ts +26 -0
- package/src/modules/static-map/StaticMapManager.ts +119 -0
- package/src/utils/animated/Animated.ts +7 -7
- package/src/utils/animated/{AnimatedShape.ts → AnimatedGeoJSON.ts} +16 -16
- package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/ClusterPropertyEntry.kt +0 -5
- package/android/src/main/java/org/maplibre/reactnative/modules/MLRNSnapshotModule.kt +0 -114
- package/ios/components/sources/shape-source/MLRNShapeSourceComponentView.h +0 -11
- package/ios/components/sources/shape-source/MLRNShapeSourceModule.h +0 -5
- package/ios/modules/snapshot/MLRNSnapshotModule.h +0 -4
- package/ios/modules/snapshot/MLRNSnapshotModule.mm +0 -77
- package/lib/commonjs/components/sources/shape-source/NativeShapeSourceModule.js.map +0 -1
- package/lib/commonjs/components/sources/shape-source/ShapeSource.js.map +0 -1
- package/lib/commonjs/modules/snapshot/NativeSnapshotModule.js.map +0 -1
- package/lib/commonjs/modules/snapshot/SnapshotManager.js +0 -61
- package/lib/commonjs/modules/snapshot/SnapshotManager.js.map +0 -1
- package/lib/commonjs/modules/snapshot/SnapshotOptions.js +0 -55
- package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +0 -1
- package/lib/commonjs/utils/animated/AnimatedShape.js.map +0 -1
- package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js +0 -5
- package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js.map +0 -1
- package/lib/module/components/sources/shape-source/ShapeSource.js.map +0 -1
- package/lib/module/modules/snapshot/NativeSnapshotModule.js +0 -5
- package/lib/module/modules/snapshot/NativeSnapshotModule.js.map +0 -1
- package/lib/module/modules/snapshot/SnapshotManager.js +0 -58
- package/lib/module/modules/snapshot/SnapshotManager.js.map +0 -1
- package/lib/module/modules/snapshot/SnapshotOptions.js +0 -50
- package/lib/module/modules/snapshot/SnapshotOptions.js.map +0 -1
- package/lib/module/utils/animated/AnimatedShape.js.map +0 -1
- package/lib/typescript/commonjs/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSource.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts +0 -19
- package/lib/typescript/commonjs/src/modules/snapshot/NativeSnapshotModule.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotManager.d.ts +0 -51
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotManager.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts +0 -23
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +0 -1
- package/lib/typescript/module/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +0 -1
- package/lib/typescript/module/src/components/sources/shape-source/ShapeSource.d.ts.map +0 -1
- package/lib/typescript/module/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts +0 -19
- package/lib/typescript/module/src/modules/snapshot/NativeSnapshotModule.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/snapshot/SnapshotManager.d.ts +0 -51
- package/lib/typescript/module/src/modules/snapshot/SnapshotManager.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts +0 -23
- package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts.map +0 -1
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +0 -1
- package/src/modules/snapshot/NativeSnapshotModule.ts +0 -23
- package/src/modules/snapshot/SnapshotManager.ts +0 -57
- package/src/modules/snapshot/SnapshotOptions.ts +0 -83
|
@@ -25,16 +25,16 @@ import org.maplibre.reactnative.components.mapview.MLRNAndroidTextureMapViewMana
|
|
|
25
25
|
import org.maplibre.reactnative.components.mapview.MLRNMapViewManager
|
|
26
26
|
import org.maplibre.reactnative.components.mapview.MLRNMapViewModule
|
|
27
27
|
import org.maplibre.reactnative.components.sources.imagesource.MLRNImageSourceManager
|
|
28
|
-
import org.maplibre.reactnative.components.sources.
|
|
29
|
-
import org.maplibre.reactnative.components.sources.
|
|
28
|
+
import org.maplibre.reactnative.components.sources.geojsonsource.MLRNGeoJSONSourceManager
|
|
29
|
+
import org.maplibre.reactnative.components.sources.geojsonsource.MLRNGeoJSONSourceModule
|
|
30
30
|
import org.maplibre.reactnative.components.sources.tilesources.rastersource.MLRNRasterSourceManager
|
|
31
31
|
import org.maplibre.reactnative.components.sources.tilesources.vectorsource.MLRNVectorSourceManager
|
|
32
32
|
import org.maplibre.reactnative.components.sources.tilesources.vectorsource.MLRNVectorSourceModule
|
|
33
33
|
import org.maplibre.reactnative.modules.MLRNLocationModule
|
|
34
34
|
import org.maplibre.reactnative.modules.MLRNLogModule
|
|
35
|
-
import org.maplibre.reactnative.modules.MLRNOfflineModule
|
|
36
35
|
import org.maplibre.reactnative.modules.MLRNNetworkModule
|
|
37
|
-
import org.maplibre.reactnative.modules.
|
|
36
|
+
import org.maplibre.reactnative.modules.MLRNOfflineModule
|
|
37
|
+
import org.maplibre.reactnative.modules.MLRNStaticMapModule
|
|
38
38
|
import org.maplibre.reactnative.utils.ReactTagResolver
|
|
39
39
|
|
|
40
40
|
class MLRNPackage : BaseReactPackage() {
|
|
@@ -53,7 +53,7 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
53
53
|
getReactTagResolver(reactContext),
|
|
54
54
|
)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
MLRNGeoJSONSourceModule.NAME -> return MLRNGeoJSONSourceModule(
|
|
57
57
|
reactContext,
|
|
58
58
|
getReactTagResolver(reactContext),
|
|
59
59
|
)
|
|
@@ -65,7 +65,7 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
65
65
|
|
|
66
66
|
MLRNOfflineModule.NAME -> return MLRNOfflineModule(reactContext)
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
MLRNStaticMapModule.NAME -> return MLRNStaticMapModule(reactContext)
|
|
69
69
|
|
|
70
70
|
MLRNLocationModule.NAME -> return MLRNLocationModule(reactContext)
|
|
71
71
|
|
|
@@ -101,10 +101,10 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
101
101
|
isTurboModule = true,
|
|
102
102
|
)
|
|
103
103
|
|
|
104
|
-
moduleInfos[
|
|
104
|
+
moduleInfos[MLRNGeoJSONSourceModule.NAME] =
|
|
105
105
|
ReactModuleInfo(
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
MLRNGeoJSONSourceModule.NAME,
|
|
107
|
+
MLRNGeoJSONSourceModule.NAME,
|
|
108
108
|
canOverrideExistingModule = false,
|
|
109
109
|
needsEagerInit = false,
|
|
110
110
|
isCxxModule = false,
|
|
@@ -131,10 +131,10 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
131
131
|
isTurboModule = true,
|
|
132
132
|
)
|
|
133
133
|
|
|
134
|
-
moduleInfos[
|
|
134
|
+
moduleInfos[MLRNStaticMapModule.NAME] =
|
|
135
135
|
ReactModuleInfo(
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
MLRNStaticMapModule.NAME,
|
|
137
|
+
MLRNStaticMapModule.NAME,
|
|
138
138
|
canOverrideExistingModule = false,
|
|
139
139
|
needsEagerInit = false,
|
|
140
140
|
isCxxModule = false,
|
|
@@ -188,7 +188,7 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
188
188
|
|
|
189
189
|
// sources
|
|
190
190
|
managers.add(MLRNImageSourceManager(reactContext))
|
|
191
|
-
managers.add(
|
|
191
|
+
managers.add(MLRNGeoJSONSourceManager(reactContext))
|
|
192
192
|
managers.add(MLRNRasterSourceManager(reactContext))
|
|
193
193
|
managers.add(MLRNVectorSourceManager(reactContext))
|
|
194
194
|
|
|
@@ -177,7 +177,7 @@ public class MLRNImages extends AbstractMapFeature {
|
|
|
177
177
|
public void addToMap(final MLRNMapView mapView) {
|
|
178
178
|
// Wait for style before adding the source to the map
|
|
179
179
|
// only then we can pre-load required images / placeholders into the style
|
|
180
|
-
// before we add the
|
|
180
|
+
// before we add the GeoJSONSource to the map
|
|
181
181
|
mapView.getStyle(new Style.OnStyleLoaded() {
|
|
182
182
|
@Override
|
|
183
183
|
public void onStyleLoaded(@NonNull Style style) {
|
|
@@ -209,8 +209,8 @@ public class MLRNImages extends AbstractMapFeature {
|
|
|
209
209
|
List<Map.Entry<String, ImageEntry>> missingImages = new ArrayList<>();
|
|
210
210
|
|
|
211
211
|
// Add image placeholder for images that are not yet available in the style. This way
|
|
212
|
-
// we can load the images asynchronously and add the
|
|
213
|
-
// The same is required when this
|
|
212
|
+
// we can load the images asynchronously and add the GeoJSONSource to the map without delay.
|
|
213
|
+
// The same is required when this GeoJSONSource is updated with new/added images and the
|
|
214
214
|
// data references them. In which case addMissingImageToStyle will take care of loading
|
|
215
215
|
// them in a similar way.
|
|
216
216
|
//
|
|
@@ -63,6 +63,7 @@ import org.maplibre.reactnative.components.sources.MLRNSource
|
|
|
63
63
|
import org.maplibre.reactnative.events.MapChangeEvent
|
|
64
64
|
import org.maplibre.reactnative.events.MapPressEvent
|
|
65
65
|
import org.maplibre.reactnative.utils.BitmapUtils
|
|
66
|
+
import org.maplibre.reactnative.utils.ConvertUtils
|
|
66
67
|
import org.maplibre.reactnative.utils.GeoJSONUtils
|
|
67
68
|
import kotlin.math.roundToInt
|
|
68
69
|
|
|
@@ -401,21 +402,12 @@ open class MLRNMapView(
|
|
|
401
402
|
}
|
|
402
403
|
}
|
|
403
404
|
|
|
404
|
-
fun isJSONValid(test: String): Boolean {
|
|
405
|
-
try {
|
|
406
|
-
JSONObject(test)
|
|
407
|
-
} catch (_: JSONException) {
|
|
408
|
-
return false
|
|
409
|
-
}
|
|
410
|
-
return true
|
|
411
|
-
}
|
|
412
|
-
|
|
413
405
|
override fun onMapReady(mapLibreMap: MapLibreMap) {
|
|
414
406
|
this.mapLibreMap = mapLibreMap
|
|
415
407
|
|
|
416
408
|
mapStyle?.let { style ->
|
|
417
409
|
mapLibreMap.setStyle(
|
|
418
|
-
if (isJSONValid(style)) {
|
|
410
|
+
if (ConvertUtils.isJSONValid(style)) {
|
|
419
411
|
Style.Builder().fromJson(style)
|
|
420
412
|
} else {
|
|
421
413
|
Style
|
|
@@ -735,7 +727,7 @@ open class MLRNMapView(
|
|
|
735
727
|
|
|
736
728
|
mapStyle?.let { style ->
|
|
737
729
|
map.setStyle(
|
|
738
|
-
if (isJSONValid(style)) {
|
|
730
|
+
if (ConvertUtils.isJSONValid(style)) {
|
|
739
731
|
Style.Builder().fromJson(style)
|
|
740
732
|
} else {
|
|
741
733
|
Style
|
package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapViewModule.kt
CHANGED
|
@@ -176,13 +176,13 @@ class MLRNMapViewModule(
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
override fun
|
|
179
|
+
override fun createStaticMapImage(
|
|
180
180
|
reactTag: Double,
|
|
181
|
-
|
|
181
|
+
output: String,
|
|
182
182
|
promise: Promise,
|
|
183
183
|
) {
|
|
184
184
|
withViewportOnUIThread(reactTag, promise) {
|
|
185
|
-
it.takeSnap(
|
|
185
|
+
it.takeSnap(output == "file") { payload ->
|
|
186
186
|
promise.resolve(payload)
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package org.maplibre.reactnative.components.sources.
|
|
1
|
+
package org.maplibre.reactnative.components.sources.geojsonsource
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import com.facebook.react.bridge.WritableArray
|
|
@@ -15,7 +15,9 @@ import org.maplibre.reactnative.components.sources.MLRNPressableSource
|
|
|
15
15
|
import org.maplibre.reactnative.utils.GeoJSONUtils
|
|
16
16
|
import java.net.URI
|
|
17
17
|
|
|
18
|
-
class
|
|
18
|
+
class MLRNGeoJSONSource(
|
|
19
|
+
context: Context,
|
|
20
|
+
) : MLRNPressableSource<GeoJsonSource>(context) {
|
|
19
21
|
private var uri: URI? = null
|
|
20
22
|
private var geoJson: String? = null
|
|
21
23
|
|
|
@@ -31,13 +33,10 @@ class MLRNShapeSource(context: Context) : MLRNPressableSource<GeoJsonSource>(con
|
|
|
31
33
|
private var clusterProperties: MutableList<MutableMap.MutableEntry<String, ClusterPropertyEntry>>? =
|
|
32
34
|
null
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
36
|
override fun addToMap(mapView: MLRNMapView) {
|
|
38
37
|
// Wait for style before adding the source to the map
|
|
39
38
|
mapView.mapLibreMap!!.getStyle {
|
|
40
|
-
super@
|
|
39
|
+
super@MLRNGeoJSONSource.addToMap(mapView)
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
|
|
@@ -150,18 +149,15 @@ class MLRNShapeSource(context: Context) : MLRNPressableSource<GeoJsonSource>(con
|
|
|
150
149
|
return options
|
|
151
150
|
}
|
|
152
151
|
|
|
153
|
-
fun getData(
|
|
154
|
-
filter: Expression?
|
|
155
|
-
): WritableMap {
|
|
152
|
+
fun getData(filter: Expression?): WritableMap {
|
|
156
153
|
if (source == null) {
|
|
157
154
|
throw IllegalStateException("Source is not yet loaded")
|
|
158
155
|
}
|
|
159
156
|
|
|
160
157
|
val features: List<Feature> = source!!.querySourceFeatures(filter)
|
|
161
158
|
|
|
162
|
-
|
|
163
159
|
return GeoJSONUtils.fromFeatureCollection(
|
|
164
|
-
FeatureCollection.fromFeatures(features)
|
|
160
|
+
FeatureCollection.fromFeatures(features),
|
|
165
161
|
)
|
|
166
162
|
}
|
|
167
163
|
|
|
@@ -175,14 +171,21 @@ class MLRNShapeSource(context: Context) : MLRNPressableSource<GeoJsonSource>(con
|
|
|
175
171
|
return zoom
|
|
176
172
|
}
|
|
177
173
|
|
|
178
|
-
fun getClusterLeaves(
|
|
174
|
+
fun getClusterLeaves(
|
|
175
|
+
clusterId: Int,
|
|
176
|
+
limit: Int,
|
|
177
|
+
offset: Int,
|
|
178
|
+
): WritableArray {
|
|
179
179
|
if (source == null) {
|
|
180
180
|
throw IllegalStateException("Source is not yet loaded")
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
val features =
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
val features =
|
|
184
|
+
source!!.getClusterLeaves(
|
|
185
|
+
createClusterFeature(clusterId),
|
|
186
|
+
limit.toLong(),
|
|
187
|
+
offset.toLong(),
|
|
188
|
+
)
|
|
186
189
|
|
|
187
190
|
return GeoJSONUtils.fromFeatureList(features.features()?.toList()!!)
|
|
188
191
|
}
|
|
@@ -202,7 +205,8 @@ class MLRNShapeSource(context: Context) : MLRNPressableSource<GeoJsonSource>(con
|
|
|
202
205
|
properties.addProperty("cluster_id", clusterId)
|
|
203
206
|
|
|
204
207
|
return Feature.fromGeometry(
|
|
205
|
-
Point.fromLngLat(0.0, 0.0),
|
|
208
|
+
Point.fromLngLat(0.0, 0.0),
|
|
209
|
+
properties,
|
|
206
210
|
)
|
|
207
211
|
}
|
|
208
212
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package org.maplibre.reactnative.components.sources.
|
|
1
|
+
package org.maplibre.reactnative.components.sources.geojsonsource
|
|
2
2
|
|
|
3
3
|
import android.util.Log
|
|
4
4
|
import com.facebook.react.bridge.Dynamic
|
|
@@ -8,8 +8,8 @@ import com.facebook.react.module.annotations.ReactModule
|
|
|
8
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
9
|
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
10
10
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
11
|
-
import com.facebook.react.viewmanagers.
|
|
12
|
-
import com.facebook.react.viewmanagers.
|
|
11
|
+
import com.facebook.react.viewmanagers.MLRNGeoJSONSourceManagerDelegate
|
|
12
|
+
import com.facebook.react.viewmanagers.MLRNGeoJSONSourceManagerInterface
|
|
13
13
|
import org.json.JSONException
|
|
14
14
|
import org.json.JSONObject
|
|
15
15
|
import org.maplibre.android.style.expressions.Expression
|
|
@@ -19,25 +19,24 @@ import java.net.MalformedURLException
|
|
|
19
19
|
import java.net.URI
|
|
20
20
|
import java.util.AbstractMap
|
|
21
21
|
|
|
22
|
-
@ReactModule(name =
|
|
23
|
-
class
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
@ReactModule(name = MLRNGeoJSONSourceManager.REACT_CLASS)
|
|
23
|
+
class MLRNGeoJSONSourceManager(
|
|
24
|
+
context: ReactApplicationContext,
|
|
25
|
+
) : MLRNSourceManager<MLRNGeoJSONSource>(context),
|
|
26
|
+
MLRNGeoJSONSourceManagerInterface<MLRNGeoJSONSource> {
|
|
27
|
+
private val delegate: MLRNGeoJSONSourceManagerDelegate<MLRNGeoJSONSource, MLRNGeoJSONSourceManager> =
|
|
28
|
+
MLRNGeoJSONSourceManagerDelegate(this)
|
|
29
29
|
|
|
30
|
+
override fun getDelegate(): ViewManagerDelegate<MLRNGeoJSONSource> = delegate
|
|
30
31
|
|
|
31
32
|
companion object {
|
|
32
|
-
const val REACT_CLASS: String = "
|
|
33
|
-
const val LOG_TAG: String = "
|
|
33
|
+
const val REACT_CLASS: String = "MLRNGeoJSONSource"
|
|
34
|
+
const val LOG_TAG: String = "MLRNGeoJSONSourceManager"
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
override fun getName(): String = REACT_CLASS
|
|
37
38
|
|
|
38
|
-
override fun createViewInstance(themedReactContext: ThemedReactContext):
|
|
39
|
-
return MLRNShapeSource(themedReactContext)
|
|
40
|
-
}
|
|
39
|
+
override fun createViewInstance(themedReactContext: ThemedReactContext): MLRNGeoJSONSource = MLRNGeoJSONSource(themedReactContext)
|
|
41
40
|
|
|
42
41
|
fun isJSONValid(test: String): Boolean {
|
|
43
42
|
try {
|
|
@@ -48,9 +47,11 @@ class MLRNShapeSourceManager(context: ReactApplicationContext) :
|
|
|
48
47
|
return true
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
52
50
|
@ReactProp(name = "data")
|
|
53
|
-
override fun setData(
|
|
51
|
+
override fun setData(
|
|
52
|
+
source: MLRNGeoJSONSource,
|
|
53
|
+
value: String?,
|
|
54
|
+
) {
|
|
54
55
|
if (value != null) {
|
|
55
56
|
if (isJSONValid(value)) {
|
|
56
57
|
source.setGeoJson(value)
|
|
@@ -65,49 +66,75 @@ class MLRNShapeSourceManager(context: ReactApplicationContext) :
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
@ReactProp(name = "maxzoom")
|
|
68
|
-
override fun setMaxzoom(
|
|
69
|
+
override fun setMaxzoom(
|
|
70
|
+
source: MLRNGeoJSONSource,
|
|
71
|
+
value: Int,
|
|
72
|
+
) {
|
|
69
73
|
source.setMaxZoom(if (value != -1) value else null)
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
@ReactProp(name = "buffer")
|
|
73
|
-
override fun setBuffer(
|
|
77
|
+
override fun setBuffer(
|
|
78
|
+
source: MLRNGeoJSONSource,
|
|
79
|
+
value: Int,
|
|
80
|
+
) {
|
|
74
81
|
source.setBuffer(if (value != -1) value else null)
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
@ReactProp(name = "tolerance")
|
|
78
|
-
override fun setTolerance(
|
|
85
|
+
override fun setTolerance(
|
|
86
|
+
source: MLRNGeoJSONSource,
|
|
87
|
+
value: Double,
|
|
88
|
+
) {
|
|
79
89
|
source.setTolerance(if (value.toInt() != -1) value else null)
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
@ReactProp(name = "lineMetrics")
|
|
83
|
-
override fun setLineMetrics(
|
|
93
|
+
override fun setLineMetrics(
|
|
94
|
+
source: MLRNGeoJSONSource,
|
|
95
|
+
lineMetrics: Boolean,
|
|
96
|
+
) {
|
|
84
97
|
source.setLineMetrics(lineMetrics)
|
|
85
98
|
}
|
|
86
99
|
|
|
87
|
-
|
|
88
100
|
@ReactProp(name = "cluster")
|
|
89
|
-
override fun setCluster(
|
|
101
|
+
override fun setCluster(
|
|
102
|
+
source: MLRNGeoJSONSource,
|
|
103
|
+
value: Boolean,
|
|
104
|
+
) {
|
|
90
105
|
source.setCluster(value)
|
|
91
106
|
}
|
|
92
107
|
|
|
93
108
|
@ReactProp(name = "clusterRadius")
|
|
94
|
-
override fun setClusterRadius(
|
|
109
|
+
override fun setClusterRadius(
|
|
110
|
+
source: MLRNGeoJSONSource,
|
|
111
|
+
value: Int,
|
|
112
|
+
) {
|
|
95
113
|
source.setClusterRadius(if (value != -1) value else null)
|
|
96
114
|
}
|
|
97
115
|
|
|
98
116
|
@ReactProp(name = "clusterMinPoints")
|
|
99
|
-
override fun setClusterMinPoints(
|
|
117
|
+
override fun setClusterMinPoints(
|
|
118
|
+
source: MLRNGeoJSONSource,
|
|
119
|
+
value: Int,
|
|
120
|
+
) {
|
|
100
121
|
source.setClusterMinPoints(if (value != -1) value else null)
|
|
101
122
|
}
|
|
102
123
|
|
|
103
124
|
@ReactProp(name = "clusterMaxZoom")
|
|
104
|
-
override fun setClusterMaxZoom(
|
|
125
|
+
override fun setClusterMaxZoom(
|
|
126
|
+
source: MLRNGeoJSONSource,
|
|
127
|
+
value: Int,
|
|
128
|
+
) {
|
|
105
129
|
source.setClusterMaxZoom(if (value != -1) value else null)
|
|
106
130
|
}
|
|
107
131
|
|
|
108
132
|
@ReactProp(name = "clusterProperties")
|
|
109
|
-
override fun setClusterProperties(
|
|
110
|
-
|
|
133
|
+
override fun setClusterProperties(
|
|
134
|
+
source: MLRNGeoJSONSource,
|
|
135
|
+
value: Dynamic,
|
|
136
|
+
) {
|
|
137
|
+
val map = value.asMap()
|
|
111
138
|
val properties: MutableList<MutableMap.MutableEntry<String, ClusterPropertyEntry>> =
|
|
112
139
|
ArrayList()
|
|
113
140
|
|
|
@@ -117,11 +144,12 @@ class MLRNShapeSourceManager(context: ReactApplicationContext) :
|
|
|
117
144
|
val name = iterator.nextKey()
|
|
118
145
|
val expressions = map.getArray(name)
|
|
119
146
|
|
|
120
|
-
val operator: Expression? =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
147
|
+
val operator: Expression? =
|
|
148
|
+
if (expressions!!.getType(0) == ReadableType.Array) {
|
|
149
|
+
ExpressionParser.from(expressions.getArray(0))
|
|
150
|
+
} else {
|
|
151
|
+
Expression.literal(expressions.getString(0)!!)
|
|
152
|
+
}
|
|
125
153
|
|
|
126
154
|
val mapping = ExpressionParser.from(expressions.getArray(1))
|
|
127
155
|
|
|
@@ -129,8 +157,9 @@ class MLRNShapeSourceManager(context: ReactApplicationContext) :
|
|
|
129
157
|
if (operator != null && mapping != null) {
|
|
130
158
|
properties.add(
|
|
131
159
|
AbstractMap.SimpleEntry<String, ClusterPropertyEntry>(
|
|
132
|
-
name,
|
|
133
|
-
|
|
160
|
+
name,
|
|
161
|
+
ClusterPropertyEntry(operator, mapping),
|
|
162
|
+
),
|
|
134
163
|
)
|
|
135
164
|
}
|
|
136
165
|
}
|
|
@@ -1,41 +1,50 @@
|
|
|
1
|
-
package org.maplibre.reactnative.components.sources.
|
|
1
|
+
package org.maplibre.reactnative.components.sources.geojsonsource
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.Promise
|
|
4
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
5
|
import com.facebook.react.bridge.ReadableArray
|
|
6
6
|
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
-
import org.maplibre.reactnative.
|
|
7
|
+
import org.maplibre.reactnative.NativeGeoJSONSourceModuleSpec
|
|
8
8
|
import org.maplibre.reactnative.utils.ExpressionParser
|
|
9
9
|
import org.maplibre.reactnative.utils.ReactTag
|
|
10
10
|
import org.maplibre.reactnative.utils.ReactTagResolver
|
|
11
11
|
|
|
12
|
-
@ReactModule(name =
|
|
13
|
-
class
|
|
14
|
-
reactContext: ReactApplicationContext,
|
|
15
|
-
|
|
12
|
+
@ReactModule(name = NativeGeoJSONSourceModuleSpec.NAME)
|
|
13
|
+
class MLRNGeoJSONSourceModule(
|
|
14
|
+
reactContext: ReactApplicationContext,
|
|
15
|
+
private val reactTagResolver: ReactTagResolver,
|
|
16
|
+
) : NativeGeoJSONSourceModuleSpec(reactContext) {
|
|
16
17
|
companion object {
|
|
17
|
-
const val NAME = "
|
|
18
|
+
const val NAME = "MLRNGeoJSONSourceModule"
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
private fun withViewportOnUIThread(
|
|
21
|
-
reactTag: ReactTag,
|
|
22
|
+
reactTag: ReactTag,
|
|
23
|
+
promise: Promise,
|
|
24
|
+
fn: (MLRNGeoJSONSource) -> Unit,
|
|
22
25
|
) {
|
|
23
26
|
reactTagResolver.withViewResolved(reactTag.toInt(), promise, fn)
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
override fun getData(
|
|
27
|
-
reactTag: Double,
|
|
30
|
+
reactTag: Double,
|
|
31
|
+
filter: ReadableArray?,
|
|
32
|
+
promise: Promise,
|
|
28
33
|
) {
|
|
29
34
|
withViewportOnUIThread(reactTag, promise) { shapeSource ->
|
|
30
35
|
promise.resolve(
|
|
31
36
|
shapeSource.getData(
|
|
32
37
|
ExpressionParser.from(filter),
|
|
33
|
-
)
|
|
38
|
+
),
|
|
34
39
|
)
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
override fun getClusterExpansionZoom(
|
|
43
|
+
override fun getClusterExpansionZoom(
|
|
44
|
+
reactTag: Double,
|
|
45
|
+
clusterId: Double,
|
|
46
|
+
promise: Promise,
|
|
47
|
+
) {
|
|
39
48
|
withViewportOnUIThread(reactTag, promise) {
|
|
40
49
|
promise.resolve(it.getClusterExpansionZoom(clusterId.toInt()))
|
|
41
50
|
}
|
|
@@ -46,7 +55,7 @@ class MLRNShapeSourceModule(
|
|
|
46
55
|
clusterId: Double,
|
|
47
56
|
limit: Double,
|
|
48
57
|
offset: Double,
|
|
49
|
-
promise: Promise
|
|
58
|
+
promise: Promise,
|
|
50
59
|
) {
|
|
51
60
|
withViewportOnUIThread(reactTag, promise) {
|
|
52
61
|
promise.resolve(it.getClusterLeaves(clusterId.toInt(), limit.toInt(), offset.toInt()))
|
|
@@ -56,7 +65,7 @@ class MLRNShapeSourceModule(
|
|
|
56
65
|
override fun getClusterChildren(
|
|
57
66
|
reactTag: Double,
|
|
58
67
|
clusterId: Double,
|
|
59
|
-
promise: Promise
|
|
68
|
+
promise: Promise,
|
|
60
69
|
) {
|
|
61
70
|
withViewportOnUIThread(reactTag, promise) {
|
|
62
71
|
promise.resolve(it.getClusterChildren(clusterId.toInt()))
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
package org.maplibre.reactnative.modules
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import android.util.TypedValue
|
|
6
|
+
import com.facebook.react.bridge.Promise
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import org.maplibre.android.camera.CameraPosition
|
|
10
|
+
import org.maplibre.android.maps.Style
|
|
11
|
+
import org.maplibre.android.snapshotter.MapSnapshot
|
|
12
|
+
import org.maplibre.android.snapshotter.MapSnapshotter
|
|
13
|
+
import org.maplibre.reactnative.NativeStaticMapModuleSpec
|
|
14
|
+
import org.maplibre.reactnative.utils.BitmapUtils
|
|
15
|
+
import org.maplibre.reactnative.utils.ConvertUtils
|
|
16
|
+
import org.maplibre.reactnative.utils.GeoJSONUtils
|
|
17
|
+
import java.util.UUID
|
|
18
|
+
|
|
19
|
+
class MLRNStaticMapModule(
|
|
20
|
+
private val reactContext: ReactApplicationContext,
|
|
21
|
+
) : NativeStaticMapModuleSpec(reactContext) {
|
|
22
|
+
companion object {
|
|
23
|
+
const val NAME = "MLRNStaticMapModule"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun getName() = NAME
|
|
27
|
+
|
|
28
|
+
// Prevent garbage collection
|
|
29
|
+
private val snapshotterMap: MutableMap<String, MapSnapshotter> = HashMap()
|
|
30
|
+
|
|
31
|
+
override fun createImage(
|
|
32
|
+
readableMap: ReadableMap,
|
|
33
|
+
promise: Promise,
|
|
34
|
+
) {
|
|
35
|
+
org.maplibre.android.storage.FileSource
|
|
36
|
+
.getInstance(reactContext)
|
|
37
|
+
.activate()
|
|
38
|
+
|
|
39
|
+
reactContext.runOnUiQueueThread {
|
|
40
|
+
val snapshotterID = UUID.randomUUID().toString()
|
|
41
|
+
val snapshotter = MapSnapshotter(reactContext, getOptions(readableMap))
|
|
42
|
+
snapshotterMap[snapshotterID] = snapshotter
|
|
43
|
+
snapshotter.start(
|
|
44
|
+
object : MapSnapshotter.SnapshotReadyCallback {
|
|
45
|
+
override fun onSnapshotReady(snapshot: MapSnapshot) {
|
|
46
|
+
val bitmap: Bitmap = snapshot.bitmap
|
|
47
|
+
val result: String? =
|
|
48
|
+
if (readableMap.getString("output") == "file") {
|
|
49
|
+
BitmapUtils.createTempFile(
|
|
50
|
+
reactContext,
|
|
51
|
+
bitmap,
|
|
52
|
+
)
|
|
53
|
+
} else if (readableMap.getString("output") == "base64") {
|
|
54
|
+
BitmapUtils.createBase64(bitmap)
|
|
55
|
+
} else {
|
|
56
|
+
null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (result == null) {
|
|
60
|
+
promise.reject(
|
|
61
|
+
NAME,
|
|
62
|
+
"Could not generate snapshot, please check Android logs for more info.",
|
|
63
|
+
)
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
promise.resolve(result)
|
|
68
|
+
snapshotterMap.remove(snapshotterID)
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
) { error ->
|
|
72
|
+
Log.w(NAME, error)
|
|
73
|
+
snapshotterMap.remove(snapshotterID)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private fun getOptions(readableMap: ReadableMap): MapSnapshotter.Options {
|
|
79
|
+
val options: MapSnapshotter.Options =
|
|
80
|
+
MapSnapshotter.Options(
|
|
81
|
+
readableMap.getDouble("width").toInt(),
|
|
82
|
+
readableMap.getDouble("height").toInt(),
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
val showLogo = if (readableMap.hasKey("logo")) readableMap.getBoolean("logo") else false
|
|
86
|
+
options.withLogo(showLogo)
|
|
87
|
+
readableMap.getString("mapStyle")?.let { mapStyle ->
|
|
88
|
+
options.withStyleBuilder(
|
|
89
|
+
if (ConvertUtils.isJSONValid(mapStyle)) {
|
|
90
|
+
Style.Builder().fromJson(mapStyle)
|
|
91
|
+
} else {
|
|
92
|
+
Style.Builder().fromUri(mapStyle)
|
|
93
|
+
},
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
options.withPixelRatio(
|
|
97
|
+
TypedValue.applyDimension(
|
|
98
|
+
TypedValue.COMPLEX_UNIT_DIP,
|
|
99
|
+
1f,
|
|
100
|
+
reactContext.resources.displayMetrics,
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if (readableMap.hasKey("center")) {
|
|
105
|
+
val center = GeoJSONUtils.toLatLng(readableMap.getArray("center"))
|
|
106
|
+
val cameraPosition: CameraPosition =
|
|
107
|
+
CameraPosition
|
|
108
|
+
.Builder()
|
|
109
|
+
.target(center)
|
|
110
|
+
.tilt(ConvertUtils.getDouble("pitch", readableMap, 0.0))
|
|
111
|
+
.bearing(ConvertUtils.getDouble("bearing", readableMap, 0.0))
|
|
112
|
+
.zoom(ConvertUtils.getDouble("zoom", readableMap, 0.0))
|
|
113
|
+
.build()
|
|
114
|
+
options.withCameraPosition(cameraPosition)
|
|
115
|
+
} else if (readableMap.hasKey("bounds")) {
|
|
116
|
+
options.withRegion(GeoJSONUtils.toLatLngBounds(readableMap.getArray("bounds")))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return options
|
|
120
|
+
}
|
|
121
|
+
}
|