@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
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
package org.maplibre.reactnative.utils;
|
|
2
|
-
|
|
3
|
-
import org.maplibre.android.style.expressions.Expression;
|
|
4
|
-
|
|
5
|
-
public class ClusterPropertyEntry {
|
|
6
|
-
public Expression operator;
|
|
7
|
-
public Expression mapping;
|
|
8
|
-
|
|
9
|
-
public ClusterPropertyEntry(Expression _operator, Expression _mapping) {
|
|
10
|
-
operator = _operator;
|
|
11
|
-
mapping = _mapping;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
package org.maplibre.reactnative.utils;
|
|
2
|
-
|
|
3
|
-
import android.graphics.PointF;
|
|
4
|
-
import android.graphics.RectF;
|
|
5
|
-
import android.util.Log;
|
|
6
|
-
|
|
7
|
-
import com.facebook.react.bridge.Arguments;
|
|
8
|
-
import com.facebook.react.bridge.NoSuchKeyException;
|
|
9
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
10
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
11
|
-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
12
|
-
import com.facebook.react.bridge.ReadableType;
|
|
13
|
-
import com.facebook.react.bridge.WritableArray;
|
|
14
|
-
import com.facebook.react.bridge.WritableMap;
|
|
15
|
-
import com.google.gson.JsonArray;
|
|
16
|
-
import com.google.gson.JsonElement;
|
|
17
|
-
import com.google.gson.JsonObject;
|
|
18
|
-
import com.google.gson.JsonPrimitive;
|
|
19
|
-
|
|
20
|
-
import java.text.NumberFormat;
|
|
21
|
-
import java.text.ParseException;
|
|
22
|
-
import java.util.ArrayList;
|
|
23
|
-
import java.util.List;
|
|
24
|
-
import java.util.Map;
|
|
25
|
-
|
|
26
|
-
public class ConvertUtils {
|
|
27
|
-
public static final String LOG_TAG = "ConvertUtils";
|
|
28
|
-
|
|
29
|
-
public static JsonObject toJsonObject(ReadableMap map) {
|
|
30
|
-
if (map == null) return null;
|
|
31
|
-
JsonObject result = new JsonObject();
|
|
32
|
-
ReadableMapKeySetIterator it = map.keySetIterator();
|
|
33
|
-
|
|
34
|
-
while (it.hasNextKey()) {
|
|
35
|
-
String key = it.nextKey();
|
|
36
|
-
switch (map.getType(key)) {
|
|
37
|
-
case Map:
|
|
38
|
-
result.add(key, toJsonObject(map.getMap(key)));
|
|
39
|
-
break;
|
|
40
|
-
case Array:
|
|
41
|
-
result.add(key, toJsonArray(map.getArray(key)));
|
|
42
|
-
break;
|
|
43
|
-
case Null:
|
|
44
|
-
result.add(key, null);
|
|
45
|
-
break;
|
|
46
|
-
case Number:
|
|
47
|
-
result.addProperty(key, map.getDouble(key));
|
|
48
|
-
break;
|
|
49
|
-
case String:
|
|
50
|
-
result.addProperty(key, map.getString(key));
|
|
51
|
-
break;
|
|
52
|
-
case Boolean:
|
|
53
|
-
result.addProperty(key, map.getBoolean(key));
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public static JsonArray toJsonArray(ReadableArray array) {
|
|
61
|
-
if (array == null) return null;
|
|
62
|
-
JsonArray result = new JsonArray(array.size());
|
|
63
|
-
for (int i = 0; i < array.size(); i++) {
|
|
64
|
-
switch (array.getType(i)) {
|
|
65
|
-
case Map:
|
|
66
|
-
result.add(toJsonObject(array.getMap(i)));
|
|
67
|
-
break;
|
|
68
|
-
case Array:
|
|
69
|
-
result.add(toJsonArray(array.getArray(i)));
|
|
70
|
-
break;
|
|
71
|
-
case Null:
|
|
72
|
-
result.add((JsonElement)null);
|
|
73
|
-
break;
|
|
74
|
-
case Number:
|
|
75
|
-
result.add(array.getDouble(i));
|
|
76
|
-
break;
|
|
77
|
-
case String:
|
|
78
|
-
result.add(array.getString(i));
|
|
79
|
-
break;
|
|
80
|
-
case Boolean:
|
|
81
|
-
result.add(array.getBoolean(i));
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public static JsonElement typedToJsonElement(ReadableMap map) {
|
|
89
|
-
if (map == null) return null;
|
|
90
|
-
|
|
91
|
-
String type = map.getString("type");
|
|
92
|
-
|
|
93
|
-
if (type.equals(ExpressionParser.TYPE_MAP)) {
|
|
94
|
-
JsonObject result = new JsonObject();
|
|
95
|
-
|
|
96
|
-
ReadableArray keyValues = map.getArray("value");
|
|
97
|
-
for (int i = 0; i < keyValues.size(); i++) {
|
|
98
|
-
ReadableArray keyValue = keyValues.getArray(i);
|
|
99
|
-
String key = keyValue.getMap(0).getString("value");
|
|
100
|
-
|
|
101
|
-
result.add(key, typedToJsonElement(keyValue.getMap(1)));
|
|
102
|
-
}
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
else if (type.equals(ExpressionParser.TYPE_ARRAY)) {
|
|
106
|
-
ReadableArray arrayValue = map.getArray("value");
|
|
107
|
-
JsonArray result = new JsonArray(arrayValue.size());
|
|
108
|
-
for (int i = 0; i < arrayValue.size(); i++) {
|
|
109
|
-
result.add(typedToJsonElement(arrayValue.getMap(i)));
|
|
110
|
-
}
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
else if (type.equals(ExpressionParser.TYPE_BOOL)) {
|
|
114
|
-
return new JsonPrimitive(map.getBoolean("value"));
|
|
115
|
-
}
|
|
116
|
-
else if (type.equals(ExpressionParser.TYPE_NUMBER)) {
|
|
117
|
-
return new JsonPrimitive(map.getDouble("value"));
|
|
118
|
-
}
|
|
119
|
-
else if (type.equals(ExpressionParser.TYPE_STRING)) {
|
|
120
|
-
return new JsonPrimitive(map.getString("value"));
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
throw new RuntimeException(String.format("Unrecognized type {}", map.getString("type")));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public static WritableArray toWritableArray(JsonArray array) {
|
|
128
|
-
WritableArray writableArray = Arguments.createArray();
|
|
129
|
-
|
|
130
|
-
for (int i = 0; i < array.size(); i++) {
|
|
131
|
-
JsonElement element = array.get(i);
|
|
132
|
-
|
|
133
|
-
if (element.isJsonArray()) {
|
|
134
|
-
writableArray.pushArray(toWritableArray(element.getAsJsonArray()));
|
|
135
|
-
} else if (element.isJsonObject()) {
|
|
136
|
-
writableArray.pushMap(toWritableMap(element.getAsJsonObject()));
|
|
137
|
-
} else if (element.isJsonPrimitive()) {
|
|
138
|
-
JsonPrimitive primitive = element.getAsJsonPrimitive();
|
|
139
|
-
|
|
140
|
-
if (primitive.isBoolean()) {
|
|
141
|
-
writableArray.pushBoolean(primitive.getAsBoolean());
|
|
142
|
-
} else if (primitive.isNumber()) {
|
|
143
|
-
writableArray.pushDouble(primitive.getAsDouble());
|
|
144
|
-
} else {
|
|
145
|
-
writableArray.pushString(primitive.getAsString());
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return writableArray;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
public static WritableMap toWritableMap(JsonObject object) {
|
|
154
|
-
WritableMap map = Arguments.createMap();
|
|
155
|
-
|
|
156
|
-
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
|
157
|
-
String propName = entry.getKey();
|
|
158
|
-
JsonElement jsonElement = entry.getValue();
|
|
159
|
-
|
|
160
|
-
if (jsonElement.isJsonPrimitive()) {
|
|
161
|
-
JsonPrimitive primitive = jsonElement.getAsJsonPrimitive();
|
|
162
|
-
|
|
163
|
-
if (primitive.isBoolean()) {
|
|
164
|
-
map.putBoolean(propName, primitive.getAsBoolean());
|
|
165
|
-
} else if (primitive.isNumber()) {
|
|
166
|
-
map.putDouble(propName, primitive.getAsDouble());
|
|
167
|
-
} else {
|
|
168
|
-
map.putString(propName, primitive.getAsString());
|
|
169
|
-
}
|
|
170
|
-
} else if (jsonElement.isJsonArray()) {
|
|
171
|
-
map.putArray(propName, toWritableArray(jsonElement.getAsJsonArray()));
|
|
172
|
-
} else if (jsonElement.isJsonObject()) {
|
|
173
|
-
map.putMap(propName, toWritableMap(jsonElement.getAsJsonObject()));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return map;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
public static Object getObjectFromString(String str) {
|
|
181
|
-
NumberFormat numberFormat = NumberFormat.getNumberInstance();
|
|
182
|
-
|
|
183
|
-
try {
|
|
184
|
-
return numberFormat.parse(str);
|
|
185
|
-
} catch (ParseException e) {
|
|
186
|
-
// ignore we're just figuring out what type this is
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return str;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
public static List<String> toStringList(ReadableArray array) {
|
|
193
|
-
List<String> list = new ArrayList<>();
|
|
194
|
-
|
|
195
|
-
if (array == null) {
|
|
196
|
-
return list;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
for (int i = 0; i < array.size(); i++) {
|
|
200
|
-
list.add(array.getString(i));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return list;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
public static PointF toPointF(ReadableArray map) {
|
|
207
|
-
return new PointF((float) map.getDouble(0), (float) map.getDouble(1));
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
public static RectF toRectF(ReadableArray array) {
|
|
211
|
-
RectF rectF = new RectF();
|
|
212
|
-
|
|
213
|
-
if (array == null) {
|
|
214
|
-
return rectF;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
rectF.set((float)array.getDouble(3), (float)array.getDouble(0), (float)array.getDouble(1), (float)array.getDouble(2));
|
|
218
|
-
return rectF;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
public static double getDouble(String key, ReadableMap map, double defaultValue) {
|
|
222
|
-
double value = defaultValue;
|
|
223
|
-
|
|
224
|
-
try {
|
|
225
|
-
value = map.getDouble(key);
|
|
226
|
-
} catch (NoSuchKeyException e) {
|
|
227
|
-
// key not found use default value
|
|
228
|
-
Log.d(LOG_TAG, String.format("No key found for %s, using default value %f", key, defaultValue));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return value;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
public static String getString(String key, ReadableMap map, String defaultValue) {
|
|
235
|
-
String value = defaultValue;
|
|
236
|
-
|
|
237
|
-
try {
|
|
238
|
-
value = map.getString(key);
|
|
239
|
-
} catch (NoSuchKeyException e) {
|
|
240
|
-
// key not found use default value
|
|
241
|
-
Log.d(LOG_TAG, String.format("No key found for %s, using default value %s", key, defaultValue));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return value;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
package org.maplibre.reactnative.utils;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.Dynamic;
|
|
4
|
-
import com.facebook.react.bridge.ReadableArray;
|
|
5
|
-
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
-
import com.google.gson.JsonArray;
|
|
7
|
-
import org.maplibre.android.style.expressions.Expression;
|
|
8
|
-
import org.maplibre.android.style.expressions.Expression.Converter;
|
|
9
|
-
|
|
10
|
-
import org.json.JSONArray;
|
|
11
|
-
|
|
12
|
-
import java.util.Locale;
|
|
13
|
-
|
|
14
|
-
import javax.annotation.Nullable;
|
|
15
|
-
|
|
16
|
-
public class ExpressionParser {
|
|
17
|
-
static final String TYPE_STRING = "string";
|
|
18
|
-
static final String TYPE_ARRAY = "array";
|
|
19
|
-
static final String TYPE_NUMBER = "number";
|
|
20
|
-
static final String TYPE_MAP = "hashmap";
|
|
21
|
-
static final String TYPE_BOOL = "boolean";
|
|
22
|
-
|
|
23
|
-
public static @Nullable Expression from(@Nullable ReadableArray rawExpressions) {
|
|
24
|
-
if (rawExpressions == null || rawExpressions.size() == 0) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return Expression.Converter.convert(ConvertUtils.toJsonArray(rawExpressions));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public static Expression fromTyped(ReadableMap rawExpressions) {
|
|
32
|
-
JsonArray array = (JsonArray)ConvertUtils.typedToJsonElement(rawExpressions);
|
|
33
|
-
return Expression.Converter.convert(array);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
public static Expression from(ReadableMap rawExpression) {
|
|
39
|
-
return Expression.raw("[" + stringExpression(rawExpression) + "]");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private static String stringExpression(ReadableMap item) {
|
|
43
|
-
String expression = "";
|
|
44
|
-
String type = item.getString("type");
|
|
45
|
-
|
|
46
|
-
if (TYPE_STRING.equals(type)) {
|
|
47
|
-
String value = item.getString("value");
|
|
48
|
-
expression = String.format(Locale.ENGLISH, "\"%s\"", value);
|
|
49
|
-
} else if (TYPE_NUMBER.equals(type)) {
|
|
50
|
-
Double value = item.getDouble("value");
|
|
51
|
-
expression = String.format(Locale.ENGLISH, "%f", value);
|
|
52
|
-
} else if (TYPE_BOOL.equals(type)) {
|
|
53
|
-
Boolean value = item.getBoolean("value");
|
|
54
|
-
expression = String.format(Locale.ENGLISH, "%b", value);
|
|
55
|
-
} else if (TYPE_ARRAY.equals(type)) {
|
|
56
|
-
ReadableArray entries = item.getArray("value");
|
|
57
|
-
|
|
58
|
-
expression += "[";
|
|
59
|
-
|
|
60
|
-
for (int i = 0; i < entries.size(); i++) {
|
|
61
|
-
String entryExpression = stringExpression(entries.getMap(i));
|
|
62
|
-
expression += entryExpression;
|
|
63
|
-
|
|
64
|
-
if (i < entries.size() - 1) {
|
|
65
|
-
expression += ",";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
expression += "]";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return expression;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
#import <React/RCTUIManager.h>
|
|
2
|
-
|
|
3
|
-
#import "MLRNShapeSource.h"
|
|
4
|
-
#import "MLRNShapeSourceManager.h"
|
|
5
|
-
|
|
6
|
-
#import "FilterParser.h"
|
|
7
|
-
|
|
8
|
-
@implementation MLRNShapeSourceManager
|
|
9
|
-
|
|
10
|
-
RCT_EXPORT_MODULE(MLRNShapeSource)
|
|
11
|
-
|
|
12
|
-
RCT_EXPORT_VIEW_PROPERTY(id, NSString)
|
|
13
|
-
RCT_EXPORT_VIEW_PROPERTY(url, NSString)
|
|
14
|
-
RCT_EXPORT_VIEW_PROPERTY(shape, NSString)
|
|
15
|
-
|
|
16
|
-
RCT_EXPORT_VIEW_PROPERTY(cluster, NSNumber)
|
|
17
|
-
RCT_EXPORT_VIEW_PROPERTY(clusterRadius, NSNumber)
|
|
18
|
-
RCT_EXPORT_VIEW_PROPERTY(clusterMinPoints, NSNumber)
|
|
19
|
-
RCT_EXPORT_VIEW_PROPERTY(clusterMaxZoomLevel, NSNumber)
|
|
20
|
-
RCT_EXPORT_VIEW_PROPERTY(clusterProperties, NSDictionary)
|
|
21
|
-
RCT_EXPORT_VIEW_PROPERTY(maxZoomLevel, NSNumber)
|
|
22
|
-
RCT_EXPORT_VIEW_PROPERTY(buffer, NSNumber)
|
|
23
|
-
RCT_EXPORT_VIEW_PROPERTY(tolerance, NSNumber)
|
|
24
|
-
RCT_EXPORT_VIEW_PROPERTY(lineMetrics, NSNumber)
|
|
25
|
-
RCT_EXPORT_VIEW_PROPERTY(images, NSDictionary)
|
|
26
|
-
RCT_EXPORT_VIEW_PROPERTY(nativeImages, NSArray)
|
|
27
|
-
RCT_EXPORT_VIEW_PROPERTY(hasPressListener, BOOL)
|
|
28
|
-
RCT_EXPORT_VIEW_PROPERTY(hitbox, NSDictionary)
|
|
29
|
-
RCT_REMAP_VIEW_PROPERTY(onMapboxShapeSourcePress, onPress, RCTBubblingEventBlock)
|
|
30
|
-
|
|
31
|
-
- (UIView *)view {
|
|
32
|
-
MLRNShapeSource *source = [MLRNShapeSource new];
|
|
33
|
-
source.bridge = self.bridge;
|
|
34
|
-
return source;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
RCT_EXPORT_METHOD(features : (nonnull NSNumber *)reactTag withFilter : (NSArray *)
|
|
38
|
-
filter resolver : (RCTPromiseResolveBlock)
|
|
39
|
-
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
40
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
41
|
-
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
42
|
-
UIView *view = viewRegistry[reactTag];
|
|
43
|
-
MLRNShapeSource *shapeSource = nil;
|
|
44
|
-
|
|
45
|
-
if ([view isKindOfClass:[MLRNShapeSource class]]) {
|
|
46
|
-
shapeSource = (MLRNShapeSource *)view;
|
|
47
|
-
} else {
|
|
48
|
-
RCTLogError(@"Invalid react tag, could not find MLRNShapeSource");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
NSPredicate *predicate = [FilterParser parse:filter];
|
|
53
|
-
NSArray<id<MLNFeature>> *shapes = [shapeSource featuresMatchingPredicate:predicate];
|
|
54
|
-
|
|
55
|
-
NSMutableArray<NSDictionary *> *features =
|
|
56
|
-
[[NSMutableArray alloc] initWithCapacity:shapes.count];
|
|
57
|
-
for (int i = 0; i < shapes.count; i++) {
|
|
58
|
-
[features addObject:shapes[i].geoJSONDictionary];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
resolve(@{@"data" : @{@"type" : @"FeatureCollection", @"features" : features}});
|
|
62
|
-
}];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
RCT_EXPORT_METHOD(getClusterExpansionZoom : (nonnull NSNumber *)reactTag featureJSON : (
|
|
66
|
-
nonnull NSString *)featureJSON resolver : (RCTPromiseResolveBlock)
|
|
67
|
-
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
68
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
69
|
-
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
70
|
-
MLRNShapeSource *shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
71
|
-
|
|
72
|
-
if (![shapeSource isKindOfClass:[MLRNShapeSource class]]) {
|
|
73
|
-
RCTLogError(@"Invalid react tag, could not find MLRNMapView");
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
double zoom = [shapeSource getClusterExpansionZoom:featureJSON];
|
|
78
|
-
if (zoom == -1) {
|
|
79
|
-
reject(@"zoom_error",
|
|
80
|
-
[NSString stringWithFormat:@"Could not get zoom for cluster %@", featureJSON], nil);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
resolve(@{@"data" : @(zoom)});
|
|
84
|
-
}];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
RCT_EXPORT_METHOD(getClusterLeaves : (nonnull NSNumber *)reactTag featureJSON : (nonnull NSString *)
|
|
88
|
-
featureJSON number : (NSUInteger)number offset : (NSUInteger)
|
|
89
|
-
offset resolver : (RCTPromiseResolveBlock)
|
|
90
|
-
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
91
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
92
|
-
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
93
|
-
MLRNShapeSource *shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
94
|
-
|
|
95
|
-
NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterLeaves:featureJSON
|
|
96
|
-
number:number
|
|
97
|
-
offset:offset];
|
|
98
|
-
|
|
99
|
-
NSMutableArray<NSDictionary *> *features =
|
|
100
|
-
[[NSMutableArray alloc] initWithCapacity:shapes.count];
|
|
101
|
-
for (int i = 0; i < shapes.count; i++) {
|
|
102
|
-
[features addObject:shapes[i].geoJSONDictionary];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
resolve(@{@"data" : @{@"type" : @"FeatureCollection", @"features" : features}});
|
|
106
|
-
}];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
RCT_EXPORT_METHOD(getClusterChildren : (nonnull NSNumber *)reactTag featureJSON : (
|
|
110
|
-
nonnull NSString *)featureJSON resolver : (RCTPromiseResolveBlock)
|
|
111
|
-
resolve rejecter : (RCTPromiseRejectBlock)reject) {
|
|
112
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *manager,
|
|
113
|
-
NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
114
|
-
MLRNShapeSource *shapeSource = (MLRNShapeSource *)viewRegistry[reactTag];
|
|
115
|
-
|
|
116
|
-
NSArray<id<MLNFeature>> *shapes = [shapeSource getClusterChildren:featureJSON];
|
|
117
|
-
|
|
118
|
-
NSMutableArray<NSDictionary *> *features =
|
|
119
|
-
[[NSMutableArray alloc] initWithCapacity:shapes.count];
|
|
120
|
-
for (int i = 0; i < shapes.count; i++) {
|
|
121
|
-
[features addObject:shapes[i].geoJSONDictionary];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
resolve(@{@"data" : @{@"type" : @"FeatureCollection", @"features" : features}});
|
|
125
|
-
}];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@end
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ShapeSource = exports.NATIVE_MODULE_NAME = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _useNativeBridge = require("../../hooks/useNativeBridge.js");
|
|
10
|
-
var _index = require("../../utils/index.js");
|
|
11
|
-
var _filterUtils = require("../../utils/filterUtils.js");
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
const MLRNModule = _reactNative.NativeModules.MLRNModule;
|
|
14
|
-
const NATIVE_MODULE_NAME = exports.NATIVE_MODULE_NAME = "MLRNShapeSource";
|
|
15
|
-
/**
|
|
16
|
-
* ShapeSource is a map content source that supplies vector shapes to be shown on the map.
|
|
17
|
-
* The shape may be a url or a GeoJSON object
|
|
18
|
-
*/
|
|
19
|
-
const ShapeSource = exports.ShapeSource = /*#__PURE__*/(0, _react.memo)(/*#__PURE__*/(0, _react.forwardRef)(({
|
|
20
|
-
id: shapeId = MLRNModule.StyleSource.DefaultSourceID,
|
|
21
|
-
...props
|
|
22
|
-
}, ref) => {
|
|
23
|
-
(0, _react.useImperativeHandle)(ref, () => ({
|
|
24
|
-
..._nativeRef.current,
|
|
25
|
-
/**
|
|
26
|
-
* Returns all features from the source that match the query parameters regardless of whether or not the feature is
|
|
27
|
-
* currently rendered on the map.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* shapeSource.features()
|
|
31
|
-
*
|
|
32
|
-
* @param {Array=} filter - an optional filter statement to filter the returned Features.
|
|
33
|
-
* @return {GeoJSON.FeatureCollection}
|
|
34
|
-
*/
|
|
35
|
-
features,
|
|
36
|
-
/**
|
|
37
|
-
* Returns the zoom needed to expand the cluster.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* const zoom = await shapeSource.getClusterExpansionZoom(clusterId);
|
|
41
|
-
*
|
|
42
|
-
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
43
|
-
* @return {number}
|
|
44
|
-
*/
|
|
45
|
-
getClusterExpansionZoom,
|
|
46
|
-
/**
|
|
47
|
-
* Returns the FeatureCollection from the cluster.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);
|
|
51
|
-
*
|
|
52
|
-
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
53
|
-
* @param {number} limit - The number of points to return.
|
|
54
|
-
* @param {number} offset - The amount of points to skip (for pagination).
|
|
55
|
-
* @return {GeoJSON.FeatureCollection}
|
|
56
|
-
*/
|
|
57
|
-
getClusterLeaves,
|
|
58
|
-
/**
|
|
59
|
-
* Returns the FeatureCollection from the cluster (on the next zoom level).
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* const collection = await shapeSource.getClusterChildren(clusterId);
|
|
63
|
-
*
|
|
64
|
-
* @param {GeoJSON.Feature} feature - The feature cluster to expand.
|
|
65
|
-
* @return {GeoJSON.FeatureCollection}
|
|
66
|
-
*/
|
|
67
|
-
getClusterChildren,
|
|
68
|
-
setNativeProps,
|
|
69
|
-
_nativeRef: _nativeRef.current
|
|
70
|
-
}));
|
|
71
|
-
const _nativeRef = (0, _react.useRef)(null);
|
|
72
|
-
const {
|
|
73
|
-
_runNativeCommand,
|
|
74
|
-
_runPendingNativeCommands,
|
|
75
|
-
_onAndroidCallback
|
|
76
|
-
} = (0, _useNativeBridge.useNativeBridge)(NATIVE_MODULE_NAME);
|
|
77
|
-
const _setNativeRef = nativeRef => {
|
|
78
|
-
_nativeRef.current = nativeRef;
|
|
79
|
-
_runPendingNativeCommands(nativeRef);
|
|
80
|
-
};
|
|
81
|
-
async function features(filter) {
|
|
82
|
-
const res = await _runNativeCommand("features", _nativeRef.current, [(0, _filterUtils.getFilter)(filter)]);
|
|
83
|
-
if ((0, _index.isAndroid)()) {
|
|
84
|
-
return JSON.parse(res.data);
|
|
85
|
-
}
|
|
86
|
-
return res.data;
|
|
87
|
-
}
|
|
88
|
-
async function getClusterExpansionZoom(feature) {
|
|
89
|
-
const res = await _runNativeCommand("getClusterExpansionZoom", _nativeRef.current, [JSON.stringify(feature)]);
|
|
90
|
-
return res.data;
|
|
91
|
-
}
|
|
92
|
-
async function getClusterLeaves(feature, limit, offset) {
|
|
93
|
-
const res = await _runNativeCommand("getClusterLeaves", _nativeRef.current, [JSON.stringify(feature), limit, offset]);
|
|
94
|
-
if ((0, _index.isAndroid)()) {
|
|
95
|
-
return JSON.parse(res.data);
|
|
96
|
-
}
|
|
97
|
-
return res.data;
|
|
98
|
-
}
|
|
99
|
-
async function getClusterChildren(feature) {
|
|
100
|
-
const res = await _runNativeCommand("getClusterChildren", _nativeRef.current, [JSON.stringify(feature)]);
|
|
101
|
-
if ((0, _index.isAndroid)()) {
|
|
102
|
-
return JSON.parse(res.data);
|
|
103
|
-
}
|
|
104
|
-
return res.data;
|
|
105
|
-
}
|
|
106
|
-
function setNativeProps(nativeProps) {
|
|
107
|
-
if (!_nativeRef.current) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const shallowProps = Object.assign({}, nativeProps);
|
|
111
|
-
|
|
112
|
-
// Adds support for Animated
|
|
113
|
-
if (shallowProps.shape && typeof shallowProps.shape !== "string") {
|
|
114
|
-
shallowProps.shape = JSON.stringify(shallowProps.shape);
|
|
115
|
-
}
|
|
116
|
-
_nativeRef.current.setNativeProps(shallowProps);
|
|
117
|
-
}
|
|
118
|
-
function _getShape() {
|
|
119
|
-
if (!props.shape) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
return (0, _index.toJSONString)(props.shape);
|
|
123
|
-
}
|
|
124
|
-
const shapeProps = {
|
|
125
|
-
id: shapeId,
|
|
126
|
-
testID: props.testID,
|
|
127
|
-
url: props.url,
|
|
128
|
-
shape: _getShape(),
|
|
129
|
-
hitbox: props.hitbox,
|
|
130
|
-
hasPressListener: !!props.onPress,
|
|
131
|
-
onMapboxShapeSourcePress: props.onPress,
|
|
132
|
-
cluster: props.cluster ? 1 : 0,
|
|
133
|
-
clusterRadius: props.clusterRadius,
|
|
134
|
-
clusterMinPoints: props.clusterMinPoints,
|
|
135
|
-
clusterMaxZoomLevel: props.clusterMaxZoomLevel,
|
|
136
|
-
clusterProperties: props.clusterProperties,
|
|
137
|
-
maxZoomLevel: props.maxZoomLevel,
|
|
138
|
-
buffer: props.buffer,
|
|
139
|
-
tolerance: props.tolerance,
|
|
140
|
-
lineMetrics: props.lineMetrics,
|
|
141
|
-
onPress: undefined,
|
|
142
|
-
ref: _setNativeRef,
|
|
143
|
-
onAndroidCallback: (0, _index.isAndroid)() ? _onAndroidCallback : undefined
|
|
144
|
-
};
|
|
145
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(MLRNShapeSource, {
|
|
146
|
-
...shapeProps,
|
|
147
|
-
children: (0, _index.cloneReactChildrenWithProps)(props.children, {
|
|
148
|
-
sourceID: shapeId
|
|
149
|
-
})
|
|
150
|
-
});
|
|
151
|
-
}));
|
|
152
|
-
const MLRNShapeSource = (0, _reactNative.requireNativeComponent)(NATIVE_MODULE_NAME);
|
|
153
|
-
//# sourceMappingURL=ShapeSource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_useNativeBridge","_index","_filterUtils","_jsxRuntime","MLRNModule","NativeModules","NATIVE_MODULE_NAME","exports","ShapeSource","memo","forwardRef","id","shapeId","StyleSource","DefaultSourceID","props","ref","useImperativeHandle","_nativeRef","current","features","getClusterExpansionZoom","getClusterLeaves","getClusterChildren","setNativeProps","useRef","_runNativeCommand","_runPendingNativeCommands","_onAndroidCallback","useNativeBridge","_setNativeRef","nativeRef","filter","res","getFilter","isAndroid","JSON","parse","data","feature","stringify","limit","offset","nativeProps","shallowProps","Object","assign","shape","_getShape","undefined","toJSONString","shapeProps","testID","url","hitbox","hasPressListener","onPress","onMapboxShapeSourcePress","cluster","clusterRadius","clusterMinPoints","clusterMaxZoomLevel","clusterProperties","maxZoomLevel","buffer","tolerance","lineMetrics","onAndroidCallback","jsx","MLRNShapeSource","children","cloneReactChildrenWithProps","sourceID","requireNativeComponent"],"sourceRoot":"../../../../src","sources":["components/sources/ShapeSource.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getFilter","filter","Array","isArray","length"],"sourceRoot":"../../../src","sources":["utils/filterUtils.ts"],"mappings":";;;;;;AAEO,SAASA,SAASA,CAACC,MAAoC,EAAY;EACxE,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAIA,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;IACjD,OAAO,EAAE;EACX;EAEA,OAAOH,MAAM;AACf","ignoreList":[]}
|