@maplibre/maplibre-react-native 10.0.0-alpha.7 → 10.0.0-alpha.9
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/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/rctmln/build.gradle +5 -5
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerView.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/MarkerViewManager.java +6 -6
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/RCTMLNMarkerView.java +5 -5
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/annotation/RCTMLNPointAnnotation.java +9 -8
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraStop.java +14 -12
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraUpdateItem.java +10 -10
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/CameraUpdateQueue.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/RCTMLNCamera.java +26 -26
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/camera/RCTMLNCameraManager.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/images/RCTMLNImages.java +12 -12
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/LocationComponentManager.java +9 -9
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/RCTMLNNativeUserLocation.java +7 -7
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/location/RCTMLNNativeUserLocationManager.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/LayerSourceInfo.java +9 -9
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNAndroidTextureMapView.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNAndroidTextureMapViewManager.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapView.java +43 -43
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/mapview/RCTMLNMapViewManager.java +6 -6
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyle.java +3 -3
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleFactory.java +14 -14
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleFunctionParser.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/RCTMLNStyleValue.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTLayer.java +8 -8
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNBackgroundLayer.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNCircleLayer.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNFillExtrusionLayer.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNFillLayer.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNHeatmapLayer.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNLineLayer.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNRasterLayer.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/layers/RCTMLNSymbolLayer.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/light/RCTMLNLight.java +6 -6
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNImageSource.java +3 -3
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNImageSourceManager.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNRasterSource.java +3 -3
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNShapeSource.java +9 -9
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNShapeSourceManager.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNTileSource.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTMLNVectorSource.java +4 -4
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/styles/sources/RCTSource.java +7 -7
- package/android/rctmln/src/main/java/com/maplibre/rctmln/events/FeatureClickEvent.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/events/MapClickEvent.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/events/PointAnnotationClickEvent.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/events/PointAnnotationDragEvent.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/location/LocationManager.java +6 -6
- package/android/rctmln/src/main/java/com/maplibre/rctmln/location/UserLocation.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/location/UserTrackingMode.java +3 -3
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLocationModule.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLogging.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNModule.java +8 -8
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNOfflineModule.java +11 -11
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNSnapshotModule.java +7 -7
- package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/ClusterPropertyEntry.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/DownloadMapImageTask.java +5 -5
- package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/ExpressionParser.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/GeoJSONUtils.java +13 -13
- package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/GeoViewport.java +3 -3
- package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/SimpleEventCallback.java +2 -2
- package/android/rctmln/src/main/java/com/maplibre/rctmln/utils/SphericalMercator.java +1 -1
- package/docs/Camera.md +1 -1
- package/docs/MapView.md +9 -9
- package/docs/MarkerView.md +1 -1
- package/docs/NativeUserLocation.md +1 -1
- package/docs/PointAnnotation.md +2 -2
- package/docs/UserLocation.md +2 -2
- package/docs/docs.json +12 -12
- package/javascript/@types/assets.d.ts +1 -1
- package/javascript/MLNModule.ts +2 -2
- package/javascript/Maplibre.ts +37 -42
- package/javascript/components/BackgroundLayer.tsx +9 -9
- package/javascript/components/Callout.tsx +19 -19
- package/javascript/components/Camera.tsx +29 -29
- package/javascript/components/CircleLayer.tsx +9 -9
- package/javascript/components/FillExtrusionLayer.tsx +9 -9
- package/javascript/components/FillLayer.tsx +9 -9
- package/javascript/components/HeadingIndicator.tsx +7 -8
- package/javascript/components/HeatmapLayer.tsx +10 -10
- package/javascript/components/ImageSource.tsx +8 -8
- package/javascript/components/Images.tsx +19 -20
- package/javascript/components/Light.tsx +15 -15
- package/javascript/components/LineLayer.tsx +9 -9
- package/javascript/components/MapView.tsx +74 -70
- package/javascript/components/MarkerView.tsx +9 -10
- package/javascript/components/NativeUserLocation.tsx +4 -4
- package/javascript/components/PointAnnotation.tsx +17 -17
- package/javascript/components/RasterLayer.tsx +9 -9
- package/javascript/components/RasterSource.tsx +10 -10
- package/javascript/components/ShapeSource.tsx +63 -61
- package/javascript/components/Style.tsx +69 -59
- package/javascript/components/SymbolLayer.tsx +10 -10
- package/javascript/components/UserLocation.tsx +23 -23
- package/javascript/components/VectorSource.tsx +19 -19
- package/javascript/components/annotations/Annotation.tsx +16 -15
- package/javascript/hooks/useAbstractLayer.ts +15 -12
- package/javascript/hooks/useAbstractSource.ts +2 -2
- package/javascript/hooks/useNativeBridge.ts +7 -7
- package/javascript/hooks/useNativeRef.ts +2 -2
- package/javascript/hooks/useOnce.ts +1 -1
- package/javascript/index.ts +2 -2
- package/javascript/modules/location/locationManager.ts +4 -4
- package/javascript/modules/offline/OfflineCreatePackOptions.ts +5 -5
- package/javascript/modules/offline/OfflinePack.ts +3 -3
- package/javascript/modules/offline/offlineManager.ts +11 -12
- package/javascript/modules/snapshot/SnapshotOptions.ts +4 -4
- package/javascript/modules/snapshot/snapshotManager.ts +2 -2
- package/javascript/requestAndroidLocationPermissions.ts +3 -3
- package/javascript/types/OnPressEvent.ts +1 -1
- package/javascript/types/index.ts +6 -2
- package/javascript/utils/BridgeValue.ts +20 -20
- package/javascript/utils/Logger.ts +14 -14
- package/javascript/utils/MaplibreStyles.d.ts +359 -359
- package/javascript/utils/StyleValue.ts +12 -12
- package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +6 -6
- package/javascript/utils/animated/Animated.ts +38 -16
- package/javascript/utils/animated/AnimatedCoordinatesArray.ts +7 -11
- package/javascript/utils/animated/AnimatedExtractCoordinateFromArray.ts +3 -3
- package/javascript/utils/animated/AnimatedPoint.ts +7 -7
- package/javascript/utils/animated/AnimatedRouteCoordinatesArray.ts +16 -20
- package/javascript/utils/animated/AnimatedShape.ts +15 -15
- package/javascript/utils/deprecation.ts +6 -3
- package/javascript/utils/filterUtils.ts +1 -1
- package/javascript/utils/geoUtils.ts +8 -8
- package/javascript/utils/index.ts +14 -14
- package/javascript/utils/styleMap.ts +18 -18
- package/package.json +28 -15
- package/plugin/build/withMapLibre.d.ts +2 -2
- package/plugin/build/withMapLibre.js +24 -24
- package/scripts/autogenerate.js +1 -1
- package/scripts/templates/RCTMLNStyleFactory.java.ejs +14 -14
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -169
- package/.prettierrc.js +0 -7
- package/.yarn/sdks/eslint/bin/eslint.js +0 -27
- package/.yarn/sdks/eslint/lib/api.js +0 -27
- package/.yarn/sdks/eslint/lib/unsupported-api.js +0 -27
- package/.yarn/sdks/eslint/package.json +0 -14
- package/.yarn/sdks/integrations.yml +0 -5
- package/.yarn/sdks/prettier/bin/prettier.cjs +0 -27
- package/.yarn/sdks/prettier/index.cjs +0 -27
- package/.yarn/sdks/prettier/package.json +0 -7
- package/.yarn/sdks/typescript/bin/tsc +0 -27
- package/.yarn/sdks/typescript/bin/tsserver +0 -27
- package/.yarn/sdks/typescript/lib/tsc.js +0 -27
- package/.yarn/sdks/typescript/lib/tsserver.js +0 -239
- package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -239
- package/.yarn/sdks/typescript/lib/typescript.js +0 -27
- package/.yarn/sdks/typescript/package.json +0 -10
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import useNativeBridge, {RNMLEvent} from '../hooks/useNativeBridge';
|
|
2
|
-
import {isFunction, toJSONString} from '../utils';
|
|
3
|
-
import {makePoint} from '../utils/geoUtils';
|
|
4
|
-
|
|
5
1
|
import React, {
|
|
6
2
|
Component,
|
|
7
3
|
SyntheticEvent,
|
|
@@ -9,21 +5,25 @@ import React, {
|
|
|
9
5
|
useImperativeHandle,
|
|
10
6
|
useRef,
|
|
11
7
|
ReactElement,
|
|
12
|
-
} from
|
|
8
|
+
} from "react";
|
|
13
9
|
import {
|
|
14
10
|
Platform,
|
|
15
11
|
StyleSheet,
|
|
16
12
|
ViewProps,
|
|
17
13
|
requireNativeComponent,
|
|
18
|
-
} from
|
|
14
|
+
} from "react-native";
|
|
15
|
+
|
|
16
|
+
import useNativeBridge, { RNMLEvent } from "../hooks/useNativeBridge";
|
|
17
|
+
import { isFunction, toJSONString } from "../utils";
|
|
18
|
+
import { makePoint } from "../utils/geoUtils";
|
|
19
19
|
|
|
20
|
-
export const NATIVE_MODULE_NAME =
|
|
20
|
+
export const NATIVE_MODULE_NAME = "RCTMLNPointAnnotation";
|
|
21
21
|
|
|
22
22
|
const styles = StyleSheet.create({
|
|
23
23
|
container: {
|
|
24
|
-
alignItems:
|
|
25
|
-
justifyContent:
|
|
26
|
-
position:
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
position: "absolute",
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -104,10 +104,10 @@ export interface PointAnnotationProps {
|
|
|
104
104
|
*/
|
|
105
105
|
children: React.ReactElement | [React.ReactElement, React.ReactElement];
|
|
106
106
|
|
|
107
|
-
style?: ViewProps[
|
|
107
|
+
style?: ViewProps["style"];
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
interface NativeProps extends Omit<PointAnnotationProps,
|
|
110
|
+
interface NativeProps extends Omit<PointAnnotationProps, "coordinate"> {
|
|
111
111
|
coordinate?: string;
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -128,7 +128,7 @@ export interface PointAnnotationRef {
|
|
|
128
128
|
const PointAnnotation = forwardRef<PointAnnotationRef, PointAnnotationProps>(
|
|
129
129
|
(
|
|
130
130
|
{
|
|
131
|
-
anchor = {x: 0.5, y: 0.5},
|
|
131
|
+
anchor = { x: 0.5, y: 0.5 },
|
|
132
132
|
draggable = false,
|
|
133
133
|
...props
|
|
134
134
|
}: PointAnnotationProps,
|
|
@@ -146,13 +146,13 @@ const PointAnnotation = forwardRef<PointAnnotationRef, PointAnnotationProps>(
|
|
|
146
146
|
}),
|
|
147
147
|
);
|
|
148
148
|
|
|
149
|
-
const {_runNativeCommand, _runPendingNativeCommands} =
|
|
149
|
+
const { _runNativeCommand, _runPendingNativeCommands } =
|
|
150
150
|
useNativeBridge(NATIVE_MODULE_NAME);
|
|
151
151
|
const _nativeRef = useRef<Component<NativeProps> | null>();
|
|
152
152
|
|
|
153
153
|
function refresh(): void {
|
|
154
|
-
if (Platform.OS ===
|
|
155
|
-
_runNativeCommand(
|
|
154
|
+
if (Platform.OS === "android") {
|
|
155
|
+
_runNativeCommand("refresh", _nativeRef.current, []);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -237,7 +237,7 @@ const PointAnnotation = forwardRef<PointAnnotationRef, PointAnnotationProps>(
|
|
|
237
237
|
|
|
238
238
|
// eslint complains about it
|
|
239
239
|
// not sure why only in this component
|
|
240
|
-
PointAnnotation.displayName =
|
|
240
|
+
PointAnnotation.displayName = "PointAnnotation";
|
|
241
241
|
|
|
242
242
|
const RCTMLNPointAnnotation =
|
|
243
243
|
requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NativeModules, requireNativeComponent } from "react-native";
|
|
3
|
+
|
|
3
4
|
import useAbstractLayer, {
|
|
4
5
|
BaseLayerProps,
|
|
5
6
|
NativeBaseProps,
|
|
6
|
-
} from
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import {NativeModules, requireNativeComponent} from 'react-native';
|
|
7
|
+
} from "../hooks/useAbstractLayer";
|
|
8
|
+
import BaseProps from "../types/BaseProps";
|
|
9
|
+
import { RasterLayerStyleProps } from "../utils/MaplibreStyles";
|
|
10
10
|
|
|
11
11
|
const MapLibreGL = NativeModules.MLNModule;
|
|
12
12
|
|
|
13
|
-
export const NATIVE_MODULE_NAME =
|
|
13
|
+
export const NATIVE_MODULE_NAME = "RCTMLNRasterLayer";
|
|
14
14
|
|
|
15
15
|
export interface RasterLayerProps extends BaseProps, BaseLayerProps {
|
|
16
16
|
/**
|
|
@@ -20,7 +20,7 @@ export interface RasterLayerProps extends BaseProps, BaseLayerProps {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
interface NativeProps
|
|
23
|
-
extends Omit<RasterLayerProps,
|
|
23
|
+
extends Omit<RasterLayerProps, "style">,
|
|
24
24
|
NativeBaseProps {}
|
|
25
25
|
|
|
26
26
|
const RCTMLNRasterLayer =
|
|
@@ -30,7 +30,7 @@ const RasterLayer: React.FC<RasterLayerProps> = ({
|
|
|
30
30
|
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
31
31
|
...props
|
|
32
32
|
}: RasterLayerProps) => {
|
|
33
|
-
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
33
|
+
const { baseProps, setNativeLayer } = useAbstractLayer<
|
|
34
34
|
RasterLayerProps,
|
|
35
35
|
NativeProps
|
|
36
36
|
>({
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import useAbstractSource from '../hooks/useAbstractSource';
|
|
4
|
-
import useOnce from '../hooks/useOnce';
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NativeModules, requireNativeComponent } from "react-native";
|
|
5
3
|
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import useAbstractSource from "../hooks/useAbstractSource";
|
|
5
|
+
import useOnce from "../hooks/useOnce";
|
|
6
|
+
import BaseProps from "../types/BaseProps";
|
|
7
|
+
import { cloneReactChildrenWithProps } from "../utils";
|
|
8
8
|
|
|
9
9
|
const MapLibreGL = NativeModules.MLNModule;
|
|
10
10
|
|
|
11
|
-
export const NATIVE_MODULE_NAME =
|
|
11
|
+
export const NATIVE_MODULE_NAME = "RCTMLNRasterSource";
|
|
12
12
|
|
|
13
13
|
const isTileTemplateUrl = (url?: string): url is string =>
|
|
14
14
|
!!url &&
|
|
15
|
-
(url.includes(
|
|
15
|
+
(url.includes("{z}") || url.includes("{bbox-") || url.includes("{quadkey}"));
|
|
16
16
|
|
|
17
17
|
interface RasterSourceProps extends BaseProps {
|
|
18
18
|
/**
|
|
@@ -80,9 +80,9 @@ const RasterSource: React.FC<RasterSourceProps> = ({
|
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
const {setNativeRef} = useAbstractSource<NativeProps>();
|
|
83
|
+
const { setNativeRef } = useAbstractSource<NativeProps>();
|
|
84
84
|
|
|
85
|
-
let {url, tileUrlTemplates} = props;
|
|
85
|
+
let { url, tileUrlTemplates } = props;
|
|
86
86
|
|
|
87
87
|
// Swapping url for tileUrlTemplates to provide backward compatiblity
|
|
88
88
|
// when RasterSource supported only tile url as url prop
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import BaseProps from '../types/BaseProps';
|
|
3
|
-
import OnPressEvent from '../types/OnPressEvent';
|
|
4
|
-
import {
|
|
5
|
-
cloneReactChildrenWithProps,
|
|
6
|
-
isAndroid,
|
|
7
|
-
isFunction,
|
|
8
|
-
toJSONString,
|
|
9
|
-
} from '../utils';
|
|
10
|
-
import {ExpressionField, FilterExpression} from '../utils/MaplibreStyles';
|
|
11
|
-
import {copyPropertiesAsDeprecated} from '../utils/deprecation';
|
|
12
|
-
import {getFilter} from '../utils/filterUtils';
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
NativeMethods,
|
|
16
|
-
NativeModules,
|
|
17
|
-
NativeSyntheticEvent,
|
|
18
|
-
requireNativeComponent,
|
|
19
|
-
} from 'react-native';
|
|
1
|
+
import { Feature, FeatureCollection } from "@turf/helpers";
|
|
20
2
|
import React, {
|
|
21
3
|
Component,
|
|
22
4
|
ReactElement,
|
|
23
5
|
memo,
|
|
24
6
|
useImperativeHandle,
|
|
25
7
|
useRef,
|
|
26
|
-
} from
|
|
27
|
-
import {
|
|
8
|
+
} from "react";
|
|
9
|
+
import {
|
|
10
|
+
NativeMethods,
|
|
11
|
+
NativeModules,
|
|
12
|
+
NativeSyntheticEvent,
|
|
13
|
+
requireNativeComponent,
|
|
14
|
+
} from "react-native";
|
|
15
|
+
|
|
16
|
+
import useNativeBridge from "../hooks/useNativeBridge";
|
|
17
|
+
import BaseProps from "../types/BaseProps";
|
|
18
|
+
import OnPressEvent from "../types/OnPressEvent";
|
|
19
|
+
import {
|
|
20
|
+
cloneReactChildrenWithProps,
|
|
21
|
+
isAndroid,
|
|
22
|
+
isFunction,
|
|
23
|
+
toJSONString,
|
|
24
|
+
} from "../utils";
|
|
25
|
+
import { ExpressionField, FilterExpression } from "../utils/MaplibreStyles";
|
|
26
|
+
import { copyPropertiesAsDeprecated } from "../utils/deprecation";
|
|
27
|
+
import { getFilter } from "../utils/filterUtils";
|
|
28
28
|
|
|
29
29
|
const MapLibreGL = NativeModules.MLNModule;
|
|
30
|
-
export const NATIVE_MODULE_NAME =
|
|
31
|
-
export const SHAPE_SOURCE_NATIVE_ASSETS_KEY =
|
|
30
|
+
export const NATIVE_MODULE_NAME = "RCTMLNShapeSource";
|
|
31
|
+
export const SHAPE_SOURCE_NATIVE_ASSETS_KEY = "assets";
|
|
32
32
|
|
|
33
33
|
interface NativeProps {
|
|
34
34
|
shape?: string;
|
|
@@ -82,7 +82,7 @@ export interface ShapeSourceProps extends BaseProps {
|
|
|
82
82
|
* Example: `{ "resultingSum": [["+", ["accumulated"], ["get", "resultingSum"]], ["get", "scalerank"]] }`
|
|
83
83
|
*
|
|
84
84
|
*/
|
|
85
|
-
clusterProperties?: {[propertyName: string]: ExpressionField};
|
|
85
|
+
clusterProperties?: { [propertyName: string]: ExpressionField };
|
|
86
86
|
/**
|
|
87
87
|
* Specifies the maximum zoom level at which to create vector tiles.
|
|
88
88
|
* A greater value produces greater detail at high zoom levels.
|
|
@@ -146,7 +146,7 @@ export interface ShapeSourceRef {
|
|
|
146
146
|
): Promise<FeatureCollection>;
|
|
147
147
|
getClusterChildren(feature: Feature): Promise<FeatureCollection>;
|
|
148
148
|
setNativeProps: (props: NativeProps) => void;
|
|
149
|
-
onPress: (event: NativeSyntheticEvent<{payload: OnPressEvent}>) => void;
|
|
149
|
+
onPress: (event: NativeSyntheticEvent<{ payload: OnPressEvent }>) => void;
|
|
150
150
|
|
|
151
151
|
// this was required by existing test __tests__/utils/animated/AnimatedCoordinatesArray.test.js
|
|
152
152
|
_nativeRef: RCTMLNShapeSourceRefType | undefined;
|
|
@@ -157,7 +157,7 @@ export interface ShapeSourceRef {
|
|
|
157
157
|
* The shape may be a url or a GeoJSON object
|
|
158
158
|
*/
|
|
159
159
|
const ShapeSource = memo(
|
|
160
|
-
React.forwardRef(
|
|
160
|
+
React.forwardRef<ShapeSourceRef, ShapeSourceProps>(
|
|
161
161
|
(
|
|
162
162
|
{
|
|
163
163
|
id: shapeId = MapLibreGL.StyleSource.DefaultSourceID,
|
|
@@ -219,8 +219,11 @@ const ShapeSource = memo(
|
|
|
219
219
|
|
|
220
220
|
const _nativeRef = useRef<RCTMLNShapeSourceRefType>();
|
|
221
221
|
|
|
222
|
-
const {
|
|
223
|
-
|
|
222
|
+
const {
|
|
223
|
+
_runNativeCommand,
|
|
224
|
+
_runPendingNativeCommands,
|
|
225
|
+
_onAndroidCallback,
|
|
226
|
+
} = useNativeBridge(NATIVE_MODULE_NAME);
|
|
224
227
|
|
|
225
228
|
const _setNativeRef = (nativeRef: RCTMLNShapeSourceRefType): void => {
|
|
226
229
|
_nativeRef.current = nativeRef;
|
|
@@ -230,11 +233,10 @@ const ShapeSource = memo(
|
|
|
230
233
|
async function features(
|
|
231
234
|
filter?: FilterExpression,
|
|
232
235
|
): Promise<FeatureCollection> {
|
|
233
|
-
const res: {data: string | FeatureCollection} =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
);
|
|
236
|
+
const res: { data: string | FeatureCollection } =
|
|
237
|
+
await _runNativeCommand("features", _nativeRef.current, [
|
|
238
|
+
getFilter(filter),
|
|
239
|
+
]);
|
|
238
240
|
|
|
239
241
|
if (isAndroid()) {
|
|
240
242
|
return JSON.parse(res.data as string);
|
|
@@ -246,20 +248,20 @@ const ShapeSource = memo(
|
|
|
246
248
|
async function getClusterExpansionZoom(
|
|
247
249
|
feature: Feature,
|
|
248
250
|
): Promise<number> {
|
|
249
|
-
if (typeof feature ===
|
|
251
|
+
if (typeof feature === "number") {
|
|
250
252
|
console.warn(
|
|
251
|
-
|
|
253
|
+
"Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
|
|
252
254
|
);
|
|
253
|
-
const res: {data: number} = await _runNativeCommand(
|
|
254
|
-
|
|
255
|
+
const res: { data: number } = await _runNativeCommand(
|
|
256
|
+
"getClusterExpansionZoomById",
|
|
255
257
|
_nativeRef.current,
|
|
256
258
|
[feature],
|
|
257
259
|
);
|
|
258
260
|
return res.data;
|
|
259
261
|
}
|
|
260
262
|
|
|
261
|
-
const res: {data: number} = await _runNativeCommand(
|
|
262
|
-
|
|
263
|
+
const res: { data: number } = await _runNativeCommand(
|
|
264
|
+
"getClusterExpansionZoom",
|
|
263
265
|
_nativeRef.current,
|
|
264
266
|
[JSON.stringify(feature)],
|
|
265
267
|
);
|
|
@@ -271,13 +273,13 @@ const ShapeSource = memo(
|
|
|
271
273
|
limit: number,
|
|
272
274
|
offset: number,
|
|
273
275
|
): Promise<FeatureCollection> {
|
|
274
|
-
if (typeof feature ===
|
|
276
|
+
if (typeof feature === "number") {
|
|
275
277
|
console.warn(
|
|
276
|
-
|
|
278
|
+
"Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
|
|
277
279
|
);
|
|
278
|
-
const res: {data: string | FeatureCollection} =
|
|
280
|
+
const res: { data: string | FeatureCollection } =
|
|
279
281
|
await _runNativeCommand(
|
|
280
|
-
|
|
282
|
+
"getClusterLeavesById",
|
|
281
283
|
_nativeRef.current,
|
|
282
284
|
[feature, limit, offset],
|
|
283
285
|
);
|
|
@@ -289,11 +291,12 @@ const ShapeSource = memo(
|
|
|
289
291
|
return res.data as FeatureCollection;
|
|
290
292
|
}
|
|
291
293
|
|
|
292
|
-
const res: {data: string | FeatureCollection} =
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
294
|
+
const res: { data: string | FeatureCollection } =
|
|
295
|
+
await _runNativeCommand("getClusterLeaves", _nativeRef.current, [
|
|
296
|
+
JSON.stringify(feature),
|
|
297
|
+
limit,
|
|
298
|
+
offset,
|
|
299
|
+
]);
|
|
297
300
|
|
|
298
301
|
if (isAndroid()) {
|
|
299
302
|
return JSON.parse(res.data as string);
|
|
@@ -305,13 +308,13 @@ const ShapeSource = memo(
|
|
|
305
308
|
async function getClusterChildren(
|
|
306
309
|
feature: Feature,
|
|
307
310
|
): Promise<FeatureCollection> {
|
|
308
|
-
if (typeof feature ===
|
|
311
|
+
if (typeof feature === "number") {
|
|
309
312
|
console.warn(
|
|
310
|
-
|
|
313
|
+
"Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.",
|
|
311
314
|
);
|
|
312
|
-
const res: {data: string | FeatureCollection} =
|
|
315
|
+
const res: { data: string | FeatureCollection } =
|
|
313
316
|
await _runNativeCommand(
|
|
314
|
-
|
|
317
|
+
"getClusterChildrenById",
|
|
315
318
|
_nativeRef.current,
|
|
316
319
|
[feature],
|
|
317
320
|
);
|
|
@@ -323,11 +326,10 @@ const ShapeSource = memo(
|
|
|
323
326
|
return res.data as FeatureCollection;
|
|
324
327
|
}
|
|
325
328
|
|
|
326
|
-
const res: {data: string | FeatureCollection} =
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
);
|
|
329
|
+
const res: { data: string | FeatureCollection } =
|
|
330
|
+
await _runNativeCommand("getClusterChildren", _nativeRef.current, [
|
|
331
|
+
JSON.stringify(feature),
|
|
332
|
+
]);
|
|
331
333
|
|
|
332
334
|
if (isAndroid()) {
|
|
333
335
|
return JSON.parse(res.data as string);
|
|
@@ -344,7 +346,7 @@ const ShapeSource = memo(
|
|
|
344
346
|
const shallowProps = Object.assign({}, nativeProps);
|
|
345
347
|
|
|
346
348
|
// Adds support for Animated
|
|
347
|
-
if (shallowProps.shape && typeof shallowProps !==
|
|
349
|
+
if (shallowProps.shape && typeof shallowProps !== "string") {
|
|
348
350
|
shallowProps.shape = JSON.stringify(shallowProps.shape);
|
|
349
351
|
}
|
|
350
352
|
|
|
@@ -359,11 +361,11 @@ const ShapeSource = memo(
|
|
|
359
361
|
}
|
|
360
362
|
|
|
361
363
|
function onPress(
|
|
362
|
-
event: NativeSyntheticEvent<{payload: OnPressEvent}>,
|
|
364
|
+
event: NativeSyntheticEvent<{ payload: OnPressEvent }>,
|
|
363
365
|
): void {
|
|
364
366
|
const {
|
|
365
367
|
nativeEvent: {
|
|
366
|
-
payload: {features, coordinates, point},
|
|
368
|
+
payload: { features, coordinates, point },
|
|
367
369
|
},
|
|
368
370
|
} = event;
|
|
369
371
|
let newEvent = {
|
|
@@ -381,7 +383,7 @@ const ShapeSource = memo(
|
|
|
381
383
|
},
|
|
382
384
|
{
|
|
383
385
|
nativeEvent: (
|
|
384
|
-
origNativeEvent: NativeSyntheticEvent<{payload: OnPressEvent}>,
|
|
386
|
+
origNativeEvent: NativeSyntheticEvent<{ payload: OnPressEvent }>,
|
|
385
387
|
) => ({
|
|
386
388
|
...origNativeEvent,
|
|
387
389
|
payload: features[0],
|