@maplibre/maplibre-react-native 11.0.0-alpha.25 → 11.0.0-alpha.27
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/gradle.properties +1 -1
- package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.kt +16 -1
- package/android/src/main/java/org/maplibre/reactnative/components/mapview/MLRNMapView.kt +20 -32
- package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNRasterSource.java +1 -1
- package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNSource.kt +228 -0
- package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNTileSource.java +0 -1
- package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNVectorSourceManager.java +2 -2
- package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/ClusterPropertyEntry.kt +5 -0
- package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/MLRNShapeSource.kt +232 -0
- package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/MLRNShapeSourceManager.kt +183 -0
- package/android/src/main/java/org/maplibre/reactnative/components/sources/shapesource/MLRNShapeSourceModule.kt +65 -0
- package/android/src/main/java/org/maplibre/reactnative/events/MapPressEvent.kt +1 -1
- package/android/src/main/java/org/maplibre/reactnative/events/MapPressEventWithFeatures.kt +24 -0
- package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.kt +203 -0
- package/android/src/main/java/org/maplibre/reactnative/utils/ExpressionParser.kt +70 -0
- package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.kt +37 -20
- package/ios/components/camera/MLRNCameraModule.mm +10 -20
- package/ios/components/map-view/MLRNMapViewModule.mm +10 -20
- package/ios/components/sources/MLRNSource.h +3 -0
- package/ios/components/sources/{MLRNShapeSource.h → shape-source/MLRNShapeSource.h} +3 -5
- package/ios/components/sources/{MLRNShapeSource.m → shape-source/MLRNShapeSource.m} +4 -12
- package/ios/components/sources/shape-source/MLRNShapeSourceComponentView.h +11 -0
- package/ios/components/sources/shape-source/MLRNShapeSourceComponentView.mm +163 -0
- package/ios/components/sources/shape-source/MLRNShapeSourceModule.h +5 -0
- package/ios/components/sources/shape-source/MLRNShapeSourceModule.mm +136 -0
- package/ios/utils/MLRNViewModuleUtils.h +35 -0
- package/ios/utils/MLRNViewModuleUtils.m +39 -0
- package/lib/commonjs/components/annotations/Annotation.js +1 -1
- package/lib/commonjs/components/annotations/Annotation.js.map +1 -1
- package/lib/commonjs/components/layers/BackgroundLayer.js.map +1 -1
- package/lib/commonjs/components/layers/CircleLayer.js.map +1 -1
- package/lib/commonjs/components/layers/FillExtrusionLayer.js.map +1 -1
- package/lib/commonjs/components/layers/HeatmapLayer.js.map +1 -1
- package/lib/commonjs/components/layers/RasterLayer.js.map +1 -1
- package/lib/commonjs/components/layers/SymbolLayer.js.map +1 -1
- package/lib/commonjs/components/map-view/MapView.js +16 -22
- package/lib/commonjs/components/map-view/MapView.js.map +1 -1
- package/lib/commonjs/components/sources/VectorSource.js +2 -2
- package/lib/commonjs/components/sources/VectorSource.js.map +1 -1
- package/lib/commonjs/components/sources/shape-source/NativeShapeSourceModule.js +9 -0
- package/lib/commonjs/components/sources/shape-source/NativeShapeSourceModule.js.map +1 -0
- package/lib/commonjs/components/sources/shape-source/ShapeSource.js +51 -0
- package/lib/commonjs/components/sources/shape-source/ShapeSource.js.map +1 -0
- package/lib/commonjs/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
- package/lib/commonjs/hooks/useAbstractLayer.js +2 -2
- package/lib/commonjs/hooks/useAbstractLayer.js.map +1 -1
- package/lib/commonjs/hooks/useFrozenId.js +16 -0
- package/lib/commonjs/hooks/useFrozenId.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/snapshot/SnapshotOptions.js.map +1 -1
- package/lib/commonjs/types/PressEventWithFeatures.js +6 -0
- package/lib/commonjs/types/PressEventWithFeatures.js.map +1 -0
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +0 -6
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/commonjs/utils/animated/Animated.js +4 -4
- package/lib/commonjs/utils/animated/Animated.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +0 -6
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedPoint.js +0 -2
- package/lib/commonjs/utils/animated/AnimatedPoint.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedShape.js +3 -16
- package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/commonjs/utils/findNodeHandle.js +16 -0
- package/lib/commonjs/utils/findNodeHandle.js.map +1 -0
- package/lib/commonjs/utils/{filterUtils.js → getFilter.js} +2 -2
- package/lib/commonjs/utils/getFilter.js.map +1 -0
- package/lib/commonjs/utils/index.js +3 -8
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/components/annotations/Annotation.js +1 -1
- package/lib/module/components/annotations/Annotation.js.map +1 -1
- package/lib/module/components/layers/BackgroundLayer.js.map +1 -1
- package/lib/module/components/layers/CircleLayer.js.map +1 -1
- package/lib/module/components/layers/FillExtrusionLayer.js.map +1 -1
- package/lib/module/components/layers/HeatmapLayer.js.map +1 -1
- package/lib/module/components/layers/RasterLayer.js.map +1 -1
- package/lib/module/components/layers/SymbolLayer.js.map +1 -1
- package/lib/module/components/map-view/MapView.js +3 -9
- package/lib/module/components/map-view/MapView.js.map +1 -1
- package/lib/module/components/sources/VectorSource.js +1 -1
- package/lib/module/components/sources/VectorSource.js.map +1 -1
- package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js +5 -0
- package/lib/module/components/sources/shape-source/NativeShapeSourceModule.js.map +1 -0
- package/lib/module/components/sources/shape-source/ShapeSource.js +46 -0
- package/lib/module/components/sources/shape-source/ShapeSource.js.map +1 -0
- package/lib/module/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
- package/lib/module/hooks/useAbstractLayer.js +1 -1
- package/lib/module/hooks/useAbstractLayer.js.map +1 -1
- package/lib/module/hooks/useFrozenId.js +12 -0
- package/lib/module/hooks/useFrozenId.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/snapshot/SnapshotOptions.js.map +1 -1
- package/lib/module/types/PressEventWithFeatures.js +4 -0
- package/lib/module/types/PressEventWithFeatures.js.map +1 -0
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +0 -7
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/module/utils/animated/Animated.js +4 -4
- package/lib/module/utils/animated/Animated.js.map +1 -1
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +0 -6
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/module/utils/animated/AnimatedPoint.js +0 -3
- package/lib/module/utils/animated/AnimatedPoint.js.map +1 -1
- package/lib/module/utils/animated/AnimatedShape.js +3 -16
- package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/module/utils/findNodeHandle.js +11 -0
- package/lib/module/utils/findNodeHandle.js.map +1 -0
- package/lib/module/utils/getFilter.js +9 -0
- package/lib/module/utils/getFilter.js.map +1 -0
- package/lib/module/utils/index.js +3 -8
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/commonjs/src/components/annotations/Annotation.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/annotations/Annotation.d.ts.map +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.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/layers/HeatmapLayer.d.ts.map +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.map +1 -1
- package/lib/typescript/commonjs/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/sources/VectorSource.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/sources/VectorSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/sources/shape-source/NativeShapeSourceModule.d.ts +10 -0
- package/lib/typescript/commonjs/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +1 -0
- package/lib/typescript/{module/src/components/sources → commonjs/src/components/sources/shape-source}/ShapeSource.d.ts +60 -41
- package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSource.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts +35 -0
- package/lib/typescript/commonjs/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useFrozenId.d.ts +2 -0
- package/lib/typescript/commonjs/src/hooks/useFrozenId.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts +1 -1
- package/lib/typescript/commonjs/src/types/MapLibreRNStyles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/PressEvent.d.ts +0 -3
- package/lib/typescript/commonjs/src/types/PressEvent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/PressEventWithFeatures.d.ts +5 -0
- package/lib/typescript/commonjs/src/types/PressEventWithFeatures.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts +4 -1
- package/lib/typescript/commonjs/src/utils/animated/Animated.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +2 -2
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/findNodeHandle.d.ts +3 -0
- package/lib/typescript/commonjs/src/utils/findNodeHandle.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/{filterUtils.d.ts → getFilter.d.ts} +2 -2
- package/lib/typescript/commonjs/src/utils/getFilter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/index.d.ts +3 -3
- package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/annotations/Annotation.d.ts +1 -1
- package/lib/typescript/module/src/components/annotations/Annotation.d.ts.map +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.map +1 -1
- package/lib/typescript/module/src/components/layers/FillExtrusionLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/layers/HeatmapLayer.d.ts.map +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.map +1 -1
- package/lib/typescript/module/src/components/map-view/MapView.d.ts.map +1 -1
- package/lib/typescript/module/src/components/sources/VectorSource.d.ts +1 -1
- package/lib/typescript/module/src/components/sources/VectorSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/sources/shape-source/NativeShapeSourceModule.d.ts +10 -0
- package/lib/typescript/module/src/components/sources/shape-source/NativeShapeSourceModule.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src/components/sources → module/src/components/sources/shape-source}/ShapeSource.d.ts +60 -41
- package/lib/typescript/module/src/components/sources/shape-source/ShapeSource.d.ts.map +1 -0
- package/lib/typescript/module/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts +35 -0
- package/lib/typescript/module/src/components/sources/shape-source/ShapeSourceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useFrozenId.d.ts +2 -0
- package/lib/typescript/module/src/hooks/useFrozenId.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/snapshot/SnapshotOptions.d.ts.map +1 -1
- package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts +1 -1
- package/lib/typescript/module/src/types/MapLibreRNStyles.d.ts.map +1 -1
- package/lib/typescript/module/src/types/PressEvent.d.ts +0 -3
- package/lib/typescript/module/src/types/PressEvent.d.ts.map +1 -1
- package/lib/typescript/module/src/types/PressEventWithFeatures.d.ts +5 -0
- package/lib/typescript/module/src/types/PressEventWithFeatures.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/Animated.d.ts +4 -1
- package/lib/typescript/module/src/utils/animated/Animated.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +2 -2
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/findNodeHandle.d.ts +3 -0
- package/lib/typescript/module/src/utils/findNodeHandle.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/{filterUtils.d.ts → getFilter.d.ts} +2 -2
- package/lib/typescript/module/src/utils/getFilter.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/index.d.ts +3 -3
- package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/components/annotations/Annotation.tsx +2 -2
- package/src/components/layers/BackgroundLayer.tsx +1 -2
- package/src/components/layers/CircleLayer.tsx +1 -2
- package/src/components/layers/FillExtrusionLayer.tsx +1 -2
- package/src/components/layers/HeatmapLayer.tsx +1 -2
- package/src/components/layers/RasterLayer.tsx +1 -2
- package/src/components/layers/SymbolLayer.tsx +1 -2
- package/src/components/map-view/MapView.tsx +2 -14
- package/src/components/sources/VectorSource.tsx +2 -2
- package/src/components/sources/shape-source/NativeShapeSourceModule.ts +31 -0
- package/src/components/sources/shape-source/ShapeSource.tsx +235 -0
- package/src/components/sources/shape-source/ShapeSourceNativeComponent.ts +48 -0
- package/src/hooks/useAbstractLayer.ts +1 -1
- package/src/hooks/useFrozenId.ts +13 -0
- package/src/index.ts +4 -3
- package/src/modules/snapshot/SnapshotOptions.ts +3 -2
- package/src/types/MapLibreRNStyles.ts +1 -1
- package/src/types/PressEvent.ts +0 -4
- package/src/types/PressEventWithFeatures.ts +5 -0
- package/src/utils/animated/AbstractAnimatedCoordinates.ts +0 -9
- package/src/utils/animated/Animated.ts +12 -5
- package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +0 -9
- package/src/utils/animated/AnimatedPoint.ts +0 -2
- package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +3 -3
- package/src/utils/animated/AnimatedShape.ts +7 -18
- package/src/utils/findNodeHandle.ts +14 -0
- package/src/utils/{filterUtils.ts → getFilter.ts} +2 -2
- package/src/utils/index.ts +12 -12
- package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNShapeSource.java +0 -248
- package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNShapeSourceManager.java +0 -216
- package/android/src/main/java/org/maplibre/reactnative/components/sources/MLRNSource.java +0 -240
- package/android/src/main/java/org/maplibre/reactnative/utils/ClusterPropertyEntry.java +0 -13
- package/android/src/main/java/org/maplibre/reactnative/utils/ConvertUtils.java +0 -246
- package/android/src/main/java/org/maplibre/reactnative/utils/ExpressionParser.java +0 -74
- package/ios/components/sources/MLRNShapeSourceManager.h +0 -6
- package/ios/components/sources/MLRNShapeSourceManager.m +0 -128
- package/lib/commonjs/components/sources/ShapeSource.js +0 -153
- package/lib/commonjs/components/sources/ShapeSource.js.map +0 -1
- package/lib/commonjs/utils/filterUtils.js.map +0 -1
- package/lib/module/components/sources/ShapeSource.js +0 -149
- package/lib/module/components/sources/ShapeSource.js.map +0 -1
- package/lib/module/utils/filterUtils.js +0 -9
- package/lib/module/utils/filterUtils.js.map +0 -1
- package/lib/typescript/commonjs/src/components/sources/ShapeSource.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/utils/filterUtils.d.ts.map +0 -1
- package/lib/typescript/module/src/components/sources/ShapeSource.d.ts.map +0 -1
- package/lib/typescript/module/src/utils/filterUtils.d.ts.map +0 -1
- package/src/components/sources/ShapeSource.tsx +0 -366
|
@@ -3,7 +3,7 @@ require "json"
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
4
|
|
|
5
5
|
# Global Variable Defaults
|
|
6
|
-
$MLRN_NATIVE_VERSION ||= "6.
|
|
6
|
+
$MLRN_NATIVE_VERSION ||= "6.22.1"
|
|
7
7
|
$MLRN_SPM_SPEC ||= {
|
|
8
8
|
url: "https://github.com/maplibre/maplibre-gl-native-distribution",
|
|
9
9
|
requirement: {
|
|
@@ -5,7 +5,7 @@ org.maplibre.reactnative.compileSdkVersion=35
|
|
|
5
5
|
org.maplibre.reactnative.ndkVersion=27.1.12297006
|
|
6
6
|
|
|
7
7
|
# MapLibre React Native
|
|
8
|
-
org.maplibre.reactnative.nativeVersion=
|
|
8
|
+
org.maplibre.reactnative.nativeVersion=12.2.3
|
|
9
9
|
org.maplibre.reactnative.nativeVariant=opengl
|
|
10
10
|
org.maplibre.reactnative.pluginVersion=3.0.2
|
|
11
11
|
org.maplibre.reactnative.turfVersion=6.0.1
|
|
@@ -26,7 +26,8 @@ import org.maplibre.reactnative.components.layers.MLRNRasterLayerManager
|
|
|
26
26
|
import org.maplibre.reactnative.components.layers.MLRNSymbolLayerManager
|
|
27
27
|
import org.maplibre.reactnative.components.sources.MLRNImageSourceManager
|
|
28
28
|
import org.maplibre.reactnative.components.sources.MLRNRasterSourceManager
|
|
29
|
-
import org.maplibre.reactnative.components.sources.MLRNShapeSourceManager
|
|
29
|
+
import org.maplibre.reactnative.components.sources.shapesource.MLRNShapeSourceManager
|
|
30
|
+
import org.maplibre.reactnative.components.sources.shapesource.MLRNShapeSourceModule
|
|
30
31
|
import org.maplibre.reactnative.components.sources.MLRNVectorSourceManager
|
|
31
32
|
import org.maplibre.reactnative.modules.MLRNLocationModule
|
|
32
33
|
import org.maplibre.reactnative.modules.MLRNLogModule
|
|
@@ -52,6 +53,11 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
52
53
|
getReactTagResolver(reactContext)
|
|
53
54
|
)
|
|
54
55
|
|
|
56
|
+
MLRNShapeSourceModule.NAME -> return MLRNShapeSourceModule(
|
|
57
|
+
reactContext,
|
|
58
|
+
getReactTagResolver(reactContext)
|
|
59
|
+
)
|
|
60
|
+
|
|
55
61
|
|
|
56
62
|
MLRNOfflineModule.REACT_CLASS -> return MLRNOfflineModule(reactContext)
|
|
57
63
|
MLRNSnapshotModule.NAME -> return MLRNSnapshotModule(reactContext)
|
|
@@ -93,6 +99,15 @@ class MLRNPackage : BaseReactPackage() {
|
|
|
93
99
|
isTurboModule = true
|
|
94
100
|
)
|
|
95
101
|
|
|
102
|
+
moduleInfos[MLRNShapeSourceModule.NAME] = ReactModuleInfo(
|
|
103
|
+
MLRNShapeSourceModule.NAME,
|
|
104
|
+
MLRNShapeSourceModule.NAME,
|
|
105
|
+
canOverrideExistingModule = false,
|
|
106
|
+
needsEagerInit = false,
|
|
107
|
+
isCxxModule = false,
|
|
108
|
+
isTurboModule = true
|
|
109
|
+
)
|
|
110
|
+
|
|
96
111
|
moduleInfos[MLRNOfflineModule.REACT_CLASS] = ReactModuleInfo(
|
|
97
112
|
MLRNOfflineModule.REACT_CLASS,
|
|
98
113
|
MLRNOfflineModule.REACT_CLASS,
|
|
@@ -64,7 +64,6 @@ import org.maplibre.reactnative.events.MapChangeEvent
|
|
|
64
64
|
import org.maplibre.reactnative.events.MapPressEvent
|
|
65
65
|
import org.maplibre.reactnative.modules.MLRNModule
|
|
66
66
|
import org.maplibre.reactnative.utils.BitmapUtils
|
|
67
|
-
import org.maplibre.reactnative.utils.ConvertUtils
|
|
68
67
|
import org.maplibre.reactnative.utils.GeoJSONUtils
|
|
69
68
|
import kotlin.math.roundToInt
|
|
70
69
|
|
|
@@ -537,24 +536,21 @@ open class MLRNMapView(
|
|
|
537
536
|
val screenPoint = mapLibreMap!!.projection.toScreenLocation(latLng)
|
|
538
537
|
val touchableSources = this.allTouchableSources
|
|
539
538
|
|
|
540
|
-
val hits: MutableMap<String
|
|
539
|
+
val hits: MutableMap<String, MutableList<Feature>?> = HashMap()
|
|
541
540
|
val hitTouchableSources: MutableList<MLRNSource<*>> = ArrayList()
|
|
542
541
|
for (touchableSource in touchableSources) {
|
|
543
|
-
val hitbox = touchableSource.
|
|
542
|
+
val hitbox = touchableSource.hitbox ?: continue
|
|
544
543
|
|
|
545
|
-
val
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
screenPoint.x - halfWidth,
|
|
551
|
-
screenPoint.y - halfHeight,
|
|
552
|
-
screenPoint.x + halfWidth,
|
|
553
|
-
screenPoint.y + halfHeight
|
|
544
|
+
val pointWithHitbox = RectF(
|
|
545
|
+
screenPoint.x - hitbox.left,
|
|
546
|
+
screenPoint.y - hitbox.top,
|
|
547
|
+
screenPoint.x + hitbox.right,
|
|
548
|
+
screenPoint.y + hitbox.bottom
|
|
554
549
|
)
|
|
555
550
|
|
|
551
|
+
|
|
556
552
|
val features =
|
|
557
|
-
mapLibreMap!!.queryRenderedFeatures(
|
|
553
|
+
mapLibreMap!!.queryRenderedFeatures(pointWithHitbox, *touchableSource.getLayerIDs())
|
|
558
554
|
if (features.isNotEmpty()) {
|
|
559
555
|
hits[touchableSource.getID()] = features
|
|
560
556
|
hitTouchableSources.add(touchableSource)
|
|
@@ -563,12 +559,15 @@ open class MLRNMapView(
|
|
|
563
559
|
|
|
564
560
|
if (hits.isNotEmpty()) {
|
|
565
561
|
val source = getTouchableSourceWithHighestZIndex(hitTouchableSources)
|
|
566
|
-
if (source != null && source.
|
|
567
|
-
source.
|
|
568
|
-
|
|
569
|
-
|
|
562
|
+
if (source != null && source.hasOnPress()) {
|
|
563
|
+
hits[source.getID()]?.let {
|
|
564
|
+
source.onPress(
|
|
565
|
+
OnPressEvent(
|
|
566
|
+
it, latLng, screenPoint
|
|
567
|
+
)
|
|
570
568
|
)
|
|
571
|
-
|
|
569
|
+
}
|
|
570
|
+
|
|
572
571
|
return true
|
|
573
572
|
}
|
|
574
573
|
}
|
|
@@ -907,13 +906,7 @@ open class MLRNMapView(
|
|
|
907
906
|
filter,
|
|
908
907
|
*(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
|
|
909
908
|
|
|
910
|
-
|
|
911
|
-
val result = Arguments.createArray()
|
|
912
|
-
for (feature in features) {
|
|
913
|
-
val jsonObject = com.google.gson.JsonParser.parseString(feature.toJson()).asJsonObject
|
|
914
|
-
result.pushMap(ConvertUtils.toWritableMap(jsonObject))
|
|
915
|
-
}
|
|
916
|
-
return result
|
|
909
|
+
return GeoJSONUtils.fromFeatureList(features)
|
|
917
910
|
}
|
|
918
911
|
|
|
919
912
|
|
|
@@ -938,12 +931,7 @@ open class MLRNMapView(
|
|
|
938
931
|
filter,
|
|
939
932
|
*(layers?.let { Array(layers.size()) { layers.getString(it) } } ?: emptyArray()))
|
|
940
933
|
|
|
941
|
-
|
|
942
|
-
for (feature in features) {
|
|
943
|
-
val jsonObject = com.google.gson.JsonParser.parseString(feature.toJson()).asJsonObject
|
|
944
|
-
result.pushMap(ConvertUtils.toWritableMap(jsonObject))
|
|
945
|
-
}
|
|
946
|
-
return result
|
|
934
|
+
return GeoJSONUtils.fromFeatureList(features)
|
|
947
935
|
}
|
|
948
936
|
|
|
949
937
|
fun project(mapCoordinate: LatLng): WritableArray {
|
|
@@ -1258,7 +1246,7 @@ open class MLRNMapView(
|
|
|
1258
1246
|
|
|
1259
1247
|
for (key in this.sources.keys) {
|
|
1260
1248
|
val source = this.sources[key]
|
|
1261
|
-
if (source != null && source.
|
|
1249
|
+
if (source != null && source.hasOnPress()) {
|
|
1262
1250
|
sources.add(source)
|
|
1263
1251
|
}
|
|
1264
1252
|
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components.sources
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.graphics.PointF
|
|
5
|
+
import android.graphics.RectF
|
|
6
|
+
import android.view.View
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
import org.maplibre.android.geometry.LatLng
|
|
9
|
+
import org.maplibre.android.log.Logger
|
|
10
|
+
import org.maplibre.android.maps.MapLibreMap
|
|
11
|
+
import org.maplibre.android.maps.Style
|
|
12
|
+
import org.maplibre.android.style.sources.Source
|
|
13
|
+
import org.maplibre.geojson.Feature
|
|
14
|
+
import org.maplibre.reactnative.components.AbstractMapFeature
|
|
15
|
+
import org.maplibre.reactnative.components.layers.MLRNLayer
|
|
16
|
+
import org.maplibre.reactnative.components.mapview.MLRNMapView
|
|
17
|
+
|
|
18
|
+
abstract class MLRNSource<T : Source?>(context: Context?) : AbstractMapFeature(context) {
|
|
19
|
+
protected var mMapView: MLRNMapView? = null
|
|
20
|
+
|
|
21
|
+
@JvmField
|
|
22
|
+
protected var mMap: MapLibreMap? = null
|
|
23
|
+
|
|
24
|
+
@JvmField
|
|
25
|
+
protected var mID: String? = null
|
|
26
|
+
|
|
27
|
+
@JvmField
|
|
28
|
+
protected var mSource: T? = null
|
|
29
|
+
protected var mHasOnPress: Boolean = false
|
|
30
|
+
|
|
31
|
+
protected var mLayers: MutableList<MLRNLayer<*>> = ArrayList()
|
|
32
|
+
private var mQueuedLayers: MutableList<MLRNLayer<*>?>? = ArrayList()
|
|
33
|
+
|
|
34
|
+
fun getID(): String {
|
|
35
|
+
return mID!!
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fun setID(id: String) {
|
|
39
|
+
mID = id
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fun getLayerIDs(): Array<String?> {
|
|
43
|
+
val layerIDs: MutableList<String?> = ArrayList()
|
|
44
|
+
|
|
45
|
+
for (i in mLayers.indices) {
|
|
46
|
+
val layer = mLayers[i]
|
|
47
|
+
layerIDs.add(layer.getID())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return layerIDs.toTypedArray<String?>()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
open fun hasOnPress(): Boolean {
|
|
54
|
+
return mHasOnPress
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fun setHasOnPress(hasPressListener: Boolean) {
|
|
58
|
+
mHasOnPress = hasPressListener
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fun setSource(source: T?) {
|
|
62
|
+
mSource = source
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var hitbox: RectF? = null
|
|
66
|
+
get() {
|
|
67
|
+
if (!hasOnPress()) {
|
|
68
|
+
return null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (field == null) {
|
|
72
|
+
return DEFAULT_HITBOX
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return field
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fun setReactHitbox(map: ReadableMap?) {
|
|
79
|
+
hitbox = if (map != null) {
|
|
80
|
+
RectF(
|
|
81
|
+
map.getDouble("left").toFloat(),
|
|
82
|
+
map.getDouble("top").toFloat(),
|
|
83
|
+
map.getDouble("right").toFloat(),
|
|
84
|
+
map.getDouble("bottom").toFloat()
|
|
85
|
+
)
|
|
86
|
+
} else {
|
|
87
|
+
null
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
val layerCount: Int
|
|
92
|
+
get() {
|
|
93
|
+
var totalCount = 0
|
|
94
|
+
|
|
95
|
+
if (mQueuedLayers != null) {
|
|
96
|
+
totalCount = mQueuedLayers!!.size
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
totalCount += mLayers.size
|
|
100
|
+
return totalCount
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
override fun addToMap(mapView: MLRNMapView) {
|
|
104
|
+
mMapView = mapView
|
|
105
|
+
mMap = mapView.mapLibreMap
|
|
106
|
+
mMap!!.getStyle { style ->
|
|
107
|
+
val existingSource = style.getSourceAs<T?>(mID!!)
|
|
108
|
+
if (existingSource != null) {
|
|
109
|
+
mSource = existingSource
|
|
110
|
+
} else {
|
|
111
|
+
mSource = makeSource()
|
|
112
|
+
style.addSource(mSource!!)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) { // first load
|
|
116
|
+
for (i in mQueuedLayers!!.indices) {
|
|
117
|
+
addLayerToMap(mQueuedLayers!![i], i)
|
|
118
|
+
}
|
|
119
|
+
mQueuedLayers = null
|
|
120
|
+
} else if (mLayers.isNotEmpty()) { // handles the case of switching style url, but keeping layers on map
|
|
121
|
+
for (i in mLayers.indices) {
|
|
122
|
+
addLayerToMap(mLayers[i], i)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
override fun removeFromMap(mapView: MLRNMapView?) {
|
|
129
|
+
if (mLayers.isNotEmpty()) {
|
|
130
|
+
for (i in mLayers.indices) {
|
|
131
|
+
val layer = mLayers[i]
|
|
132
|
+
layer.removeFromMap(mMapView)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (mQueuedLayers != null) {
|
|
136
|
+
mQueuedLayers!!.clear()
|
|
137
|
+
}
|
|
138
|
+
if (mMap != null && mSource != null && mMap!!.style != null) {
|
|
139
|
+
try {
|
|
140
|
+
mMap!!.style!!.removeSource(mSource!!)
|
|
141
|
+
} catch (ex: Throwable) {
|
|
142
|
+
Logger.w(
|
|
143
|
+
LOG_TAG,
|
|
144
|
+
String.format("MLRNSource.removeFromMap: %s - %s", mSource, ex.message),
|
|
145
|
+
ex
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
fun addLayer(childView: View?, childPosition: Int) {
|
|
152
|
+
if (childView !is MLRNLayer<*>) {
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (mMap == null) {
|
|
157
|
+
mQueuedLayers!!.add(childPosition, childView)
|
|
158
|
+
} else {
|
|
159
|
+
addLayerToMap(childView, childPosition)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fun removeLayer(childPosition: Int) {
|
|
164
|
+
val layer: MLRNLayer<*>? = if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
|
|
165
|
+
mQueuedLayers!![childPosition]
|
|
166
|
+
} else {
|
|
167
|
+
mLayers[childPosition]
|
|
168
|
+
}
|
|
169
|
+
removeLayerFromMap(layer, childPosition)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
fun getLayerAt(childPosition: Int): MLRNLayer<*>? {
|
|
173
|
+
if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
|
|
174
|
+
return mQueuedLayers!![childPosition]
|
|
175
|
+
}
|
|
176
|
+
return mLayers[childPosition]
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
protected fun addLayerToMap(layer: MLRNLayer<*>?, childPosition: Int) {
|
|
180
|
+
if (mMapView == null || layer == null) {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
layer.addToMap(mMapView)
|
|
185
|
+
if (!mLayers.contains(layer)) {
|
|
186
|
+
mLayers.add(childPosition, layer)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
protected fun removeLayerFromMap(layer: MLRNLayer<*>?, childPosition: Int) {
|
|
191
|
+
if (mMapView != null && layer != null) {
|
|
192
|
+
layer.removeFromMap(mMapView)
|
|
193
|
+
}
|
|
194
|
+
if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
|
|
195
|
+
mQueuedLayers!!.removeAt(childPosition)
|
|
196
|
+
} else {
|
|
197
|
+
mLayers.removeAt(childPosition)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
val style: Style?
|
|
202
|
+
get() {
|
|
203
|
+
if (mMap == null) return null
|
|
204
|
+
return mMap!!.style
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
abstract fun makeSource(): T?
|
|
208
|
+
|
|
209
|
+
class OnPressEvent(
|
|
210
|
+
@JvmField var features: MutableList<Feature>,
|
|
211
|
+
@JvmField var latLng: LatLng,
|
|
212
|
+
@JvmField var screenPoint: PointF
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
abstract fun onPress(event: OnPressEvent)
|
|
216
|
+
|
|
217
|
+
companion object {
|
|
218
|
+
const val DEFAULT_ID: String = "composite"
|
|
219
|
+
const val LOG_TAG: String = "MLRNSource"
|
|
220
|
+
|
|
221
|
+
val DEFAULT_HITBOX: RectF = RectF(22.0f, 22.0f, 22.0f, 22.0f)
|
|
222
|
+
|
|
223
|
+
@JvmStatic
|
|
224
|
+
fun isDefaultSource(sourceID: String?): Boolean {
|
|
225
|
+
return DEFAULT_ID == sourceID
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -37,12 +37,12 @@ public class MLRNVectorSourceManager extends MLRNTileSourceManager<MLRNVectorSou
|
|
|
37
37
|
|
|
38
38
|
@ReactProp(name = "hasPressListener")
|
|
39
39
|
public void setHasPressListener(MLRNVectorSource source, boolean hasPressListener) {
|
|
40
|
-
source.
|
|
40
|
+
source.setHasOnPress(hasPressListener);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
@ReactProp(name="hitbox")
|
|
44
44
|
public void setHitbox(MLRNVectorSource source, ReadableMap map) {
|
|
45
|
-
source.
|
|
45
|
+
source.setReactHitbox(map);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
@Override
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
package org.maplibre.reactnative.components.sources.shapesource
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.bridge.ReactContext
|
|
5
|
+
import com.facebook.react.bridge.WritableArray
|
|
6
|
+
import com.facebook.react.bridge.WritableMap
|
|
7
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
8
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
9
|
+
import com.google.gson.JsonObject
|
|
10
|
+
import org.maplibre.android.style.expressions.Expression
|
|
11
|
+
import org.maplibre.android.style.sources.GeoJsonOptions
|
|
12
|
+
import org.maplibre.android.style.sources.GeoJsonSource
|
|
13
|
+
import org.maplibre.geojson.Feature
|
|
14
|
+
import org.maplibre.geojson.FeatureCollection
|
|
15
|
+
import org.maplibre.geojson.Point
|
|
16
|
+
import org.maplibre.reactnative.components.mapview.MLRNMapView
|
|
17
|
+
import org.maplibre.reactnative.components.sources.MLRNSource
|
|
18
|
+
import org.maplibre.reactnative.events.MapPressEventWithFeatures
|
|
19
|
+
import org.maplibre.reactnative.utils.GeoJSONUtils
|
|
20
|
+
import java.net.URI
|
|
21
|
+
|
|
22
|
+
class MLRNShapeSource(context: Context) : MLRNSource<GeoJsonSource?>(context) {
|
|
23
|
+
private var uri: URI? = null
|
|
24
|
+
private var geoJson: String? = null
|
|
25
|
+
|
|
26
|
+
private var maxZoom: Int? = null
|
|
27
|
+
private var buffer: Int? = null
|
|
28
|
+
private var tolerance: Double? = null
|
|
29
|
+
private var lineMetrics: Boolean? = null
|
|
30
|
+
|
|
31
|
+
private var cluster: Boolean? = null
|
|
32
|
+
private var clusterRadius: Int? = null
|
|
33
|
+
private var clusterMinPoints: Int? = null
|
|
34
|
+
private var clusterMaxZoom: Int? = null
|
|
35
|
+
private var clusterProperties: MutableList<MutableMap.MutableEntry<String, ClusterPropertyEntry>>? =
|
|
36
|
+
null
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
val eventDispatcher: EventDispatcher?
|
|
40
|
+
get() {
|
|
41
|
+
val reactContext = context as ReactContext
|
|
42
|
+
|
|
43
|
+
return UIManagerHelper.getEventDispatcherForReactTag(reactContext, getId())
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
val surfaceId: Int
|
|
47
|
+
get() {
|
|
48
|
+
val reactContext = context as ReactContext
|
|
49
|
+
|
|
50
|
+
return UIManagerHelper.getSurfaceId(reactContext)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override fun addToMap(mapView: MLRNMapView) {
|
|
54
|
+
// Wait for style before adding the source to the map
|
|
55
|
+
mapView.mapLibreMap!!.getStyle {
|
|
56
|
+
super@MLRNShapeSource.addToMap(mapView)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override fun makeSource(): GeoJsonSource {
|
|
61
|
+
val options = this.options
|
|
62
|
+
|
|
63
|
+
if (geoJson != null) {
|
|
64
|
+
return GeoJsonSource(mID, geoJson, options)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return GeoJsonSource(mID, uri!!, options)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fun setURI(url: URI) {
|
|
71
|
+
uri = url
|
|
72
|
+
|
|
73
|
+
if (mSource != null && mMapView != null && !mMapView!!.isDestroyed) {
|
|
74
|
+
mSource!!.setUri(uri!!)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fun setGeoJson(geoJson: String?) {
|
|
79
|
+
this.geoJson = geoJson
|
|
80
|
+
|
|
81
|
+
if (mSource != null && mMapView != null && !mMapView!!.isDestroyed) {
|
|
82
|
+
mSource!!.setGeoJson(geoJson!!)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fun setMaxZoom(value: Int?) {
|
|
87
|
+
this.maxZoom = value
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fun setBuffer(value: Int?) {
|
|
91
|
+
this.buffer = value
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
fun setTolerance(value: Double?) {
|
|
95
|
+
this.tolerance = value
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fun setLineMetrics(lineMetrics: Boolean) {
|
|
99
|
+
this.lineMetrics = lineMetrics
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fun setCluster(cluster: Boolean) {
|
|
103
|
+
this.cluster = cluster
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
fun setClusterRadius(clusterRadius: Int?) {
|
|
107
|
+
this.clusterRadius = clusterRadius
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fun setClusterMinPoints(clusterMinPoints: Int?) {
|
|
111
|
+
this.clusterMinPoints = clusterMinPoints
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
fun setClusterMaxZoom(clusterMaxZoom: Int?) {
|
|
115
|
+
this.clusterMaxZoom = clusterMaxZoom
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fun setClusterProperties(clusterProperties: MutableList<MutableMap.MutableEntry<String, ClusterPropertyEntry>>?) {
|
|
119
|
+
this.clusterProperties = clusterProperties
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
override fun onPress(event: OnPressEvent) {
|
|
124
|
+
val event = MapPressEventWithFeatures(
|
|
125
|
+
surfaceId, id, "onPress", event.latLng, event.screenPoint, event.features
|
|
126
|
+
)
|
|
127
|
+
eventDispatcher?.dispatchEvent(event)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private val options: GeoJsonOptions
|
|
131
|
+
get() {
|
|
132
|
+
val options = GeoJsonOptions()
|
|
133
|
+
|
|
134
|
+
if (cluster != null) {
|
|
135
|
+
options.withCluster(cluster!!)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (clusterRadius != null) {
|
|
139
|
+
options.withClusterRadius(clusterRadius!!)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (clusterMinPoints != null) {
|
|
143
|
+
options.withClusterMinPoints(clusterMinPoints!!)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (clusterMaxZoom != null) {
|
|
147
|
+
options.withClusterMaxZoom(clusterMaxZoom!!)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (clusterProperties != null) {
|
|
151
|
+
for (entry in clusterProperties) {
|
|
152
|
+
val property: ClusterPropertyEntry = entry.value
|
|
153
|
+
|
|
154
|
+
options.withClusterProperty(entry.key, property.operator, property.mapping)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (maxZoom != null) {
|
|
159
|
+
options.withMaxZoom(maxZoom!!)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (buffer != null) {
|
|
163
|
+
options.withBuffer(buffer!!)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (tolerance != null) {
|
|
167
|
+
options.withTolerance(tolerance!!.toFloat())
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (lineMetrics != null) {
|
|
171
|
+
options.withLineMetrics(lineMetrics!!)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return options
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
fun getData(
|
|
178
|
+
filter: Expression?
|
|
179
|
+
): WritableMap {
|
|
180
|
+
if (mSource == null) {
|
|
181
|
+
throw IllegalStateException("Source is not yet loaded")
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
val features: List<Feature> = mSource!!.querySourceFeatures(filter)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
return GeoJSONUtils.fromFeatureCollection(
|
|
188
|
+
FeatureCollection.fromFeatures(features)
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
fun getClusterExpansionZoom(clusterId: Int): Int {
|
|
193
|
+
if (mSource == null) {
|
|
194
|
+
throw IllegalStateException("Source is not yet loaded")
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
val zoom = mSource!!.getClusterExpansionZoom(createClusterFeature(clusterId))
|
|
198
|
+
|
|
199
|
+
return zoom
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
fun getClusterLeaves(clusterId: Int, limit: Int, offset: Int): WritableArray {
|
|
203
|
+
if (mSource == null) {
|
|
204
|
+
throw IllegalStateException("Source is not yet loaded")
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
val features = mSource!!.getClusterLeaves(
|
|
208
|
+
createClusterFeature(clusterId), limit.toLong(), offset.toLong()
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
return GeoJSONUtils.fromFeatureList(features.features()?.toList()!!)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
fun getClusterChildren(clusterId: Int): WritableArray {
|
|
215
|
+
if (mSource == null) {
|
|
216
|
+
throw IllegalStateException("Source is not yet loaded")
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
val leaves = mSource!!.getClusterChildren(createClusterFeature(clusterId))
|
|
220
|
+
|
|
221
|
+
return GeoJSONUtils.fromFeatureList(leaves.features()!!)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private fun createClusterFeature(clusterId: Int): Feature {
|
|
225
|
+
val properties = JsonObject()
|
|
226
|
+
properties.addProperty("cluster_id", clusterId)
|
|
227
|
+
|
|
228
|
+
return Feature.fromGeometry(
|
|
229
|
+
Point.fromLngLat(0.0, 0.0), properties
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
}
|