@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,40 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {SHAPE_SOURCE_NATIVE_ASSETS_KEY} from './ShapeSource';
|
|
4
|
-
|
|
5
|
-
import React, {ReactElement} from 'react';
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
6
2
|
import {
|
|
7
3
|
requireNativeComponent,
|
|
8
4
|
Image,
|
|
9
5
|
NativeSyntheticEvent,
|
|
10
6
|
ImageSourcePropType,
|
|
11
7
|
ImageURISource,
|
|
12
|
-
} from
|
|
8
|
+
} from "react-native";
|
|
9
|
+
|
|
10
|
+
import { SHAPE_SOURCE_NATIVE_ASSETS_KEY } from "./ShapeSource";
|
|
11
|
+
import BaseProps from "../types/BaseProps";
|
|
13
12
|
|
|
14
|
-
export const NATIVE_MODULE_NAME =
|
|
13
|
+
export const NATIVE_MODULE_NAME = "RCTMLNImages";
|
|
15
14
|
|
|
16
15
|
export type ImageEntry = string | ImageSourcePropType;
|
|
17
16
|
|
|
18
17
|
function _isUrlOrPath(value: ImageEntry): boolean {
|
|
19
18
|
return (
|
|
20
|
-
(typeof value ===
|
|
21
|
-
(value.startsWith(
|
|
22
|
-
value.startsWith(
|
|
23
|
-
value.startsWith(
|
|
24
|
-
value.startsWith(
|
|
25
|
-
value.startsWith(
|
|
26
|
-
value.startsWith(
|
|
19
|
+
(typeof value === "string" || value instanceof String) &&
|
|
20
|
+
(value.startsWith("file://") ||
|
|
21
|
+
value.startsWith("http://") ||
|
|
22
|
+
value.startsWith("https://") ||
|
|
23
|
+
value.startsWith("data:") ||
|
|
24
|
+
value.startsWith("asset://") ||
|
|
25
|
+
value.startsWith("/"))
|
|
27
26
|
);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
function _isImageSourcePropType(
|
|
31
30
|
value: ImageEntry,
|
|
32
31
|
): value is ImageSourcePropType {
|
|
33
|
-
if (typeof value ===
|
|
32
|
+
if (typeof value === "number" || value instanceof Number) {
|
|
34
33
|
return true;
|
|
35
34
|
}
|
|
36
35
|
const valueAsSource = value as ImageURISource;
|
|
37
|
-
return !!valueAsSource.uri && typeof valueAsSource.uri ===
|
|
36
|
+
return !!valueAsSource.uri && typeof valueAsSource.uri === "string";
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
interface ImagesProps extends BaseProps {
|
|
@@ -43,7 +42,7 @@ interface ImagesProps extends BaseProps {
|
|
|
43
42
|
* Keys are names - see iconImage expressions, values can be either urls-s objects
|
|
44
43
|
* with format {uri: 'http://...'}` or `require('image.png')` or `import 'image.png'`
|
|
45
44
|
*/
|
|
46
|
-
images?: {[key: string]: ImageEntry};
|
|
45
|
+
images?: { [key: string]: ImageEntry };
|
|
47
46
|
/**
|
|
48
47
|
* If you have an asset under Image.xcassets on iOS and the drawables directory on android
|
|
49
48
|
* you can specify an array of string names with assets as the key `['pin']`.
|
|
@@ -69,14 +68,14 @@ const Images = ({
|
|
|
69
68
|
children,
|
|
70
69
|
}: ImagesProps): ReactElement => {
|
|
71
70
|
const _getImages = (): {
|
|
72
|
-
images?: {[key: string]: ImageEntry};
|
|
71
|
+
images?: { [key: string]: ImageEntry };
|
|
73
72
|
nativeImages?: ImageEntry[];
|
|
74
73
|
} => {
|
|
75
74
|
if (!images && !nativeAssetImages) {
|
|
76
75
|
return {};
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
const imagesResult: {[key: string]: ImageEntry} = {};
|
|
78
|
+
const imagesResult: { [key: string]: ImageEntry } = {};
|
|
80
79
|
let nativeImages: ImageEntry[] = [];
|
|
81
80
|
|
|
82
81
|
if (images) {
|
|
@@ -113,7 +112,7 @@ const Images = ({
|
|
|
113
112
|
};
|
|
114
113
|
|
|
115
114
|
const _onImageMissing = (
|
|
116
|
-
event: NativeSyntheticEvent<{payload: {imageKey: string}}>,
|
|
115
|
+
event: NativeSyntheticEvent<{ payload: { imageKey: string } }>,
|
|
117
116
|
): void => {
|
|
118
117
|
if (onImageMissing) {
|
|
119
118
|
onImageMissing(event.nativeEvent.payload.imageKey);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {StyleValue} from '../utils/StyleValue';
|
|
4
|
-
import {BaseLayerProps} from '../hooks/useAbstractLayer';
|
|
5
|
-
import useAbstractLayer from '../hooks/useAbstractLayer';
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { requireNativeComponent } from "react-native";
|
|
6
3
|
|
|
7
|
-
import
|
|
8
|
-
import
|
|
4
|
+
import useAbstractLayer, { BaseLayerProps } from "../hooks/useAbstractLayer";
|
|
5
|
+
import BaseProps from "../types/BaseProps";
|
|
6
|
+
import { LightLayerStyleProps } from "../utils/MaplibreStyles";
|
|
7
|
+
import { StyleValue } from "../utils/StyleValue";
|
|
9
8
|
|
|
10
|
-
export const NATIVE_MODULE_NAME =
|
|
9
|
+
export const NATIVE_MODULE_NAME = "RCTMLNLight";
|
|
11
10
|
|
|
12
11
|
interface LightProps extends BaseProps, BaseLayerProps {
|
|
13
12
|
/**
|
|
@@ -16,8 +15,8 @@ interface LightProps extends BaseProps, BaseLayerProps {
|
|
|
16
15
|
style?: LightLayerStyleProps;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
interface NativeProps extends Omit<LightProps,
|
|
20
|
-
reactStyle?: {[key: string]: StyleValue};
|
|
18
|
+
interface NativeProps extends Omit<LightProps, "style"> {
|
|
19
|
+
reactStyle?: { [key: string]: StyleValue };
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
const RCTMLNLight = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
@@ -26,11 +25,12 @@ const RCTMLNLight = requireNativeComponent<NativeProps>(NATIVE_MODULE_NAME);
|
|
|
26
25
|
* Light represents the light source for extruded geometries
|
|
27
26
|
*/
|
|
28
27
|
const Light: React.FC<LightProps> = (props: LightProps) => {
|
|
29
|
-
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
const { baseProps, setNativeLayer } = useAbstractLayer<
|
|
29
|
+
LightProps,
|
|
30
|
+
NativeProps
|
|
31
|
+
>({
|
|
32
|
+
...props,
|
|
33
|
+
});
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
36
|
<RCTMLNLight ref={setNativeLayer} testID="rctmlnLight" {...baseProps} />
|
|
@@ -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 { LineLayerStyleProps } 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 = "RCTMLNLineLayer";
|
|
14
14
|
|
|
15
15
|
export interface LineLayerProps extends BaseProps, BaseLayerProps {
|
|
16
16
|
/**
|
|
@@ -19,7 +19,7 @@ export interface LineLayerProps extends BaseProps, BaseLayerProps {
|
|
|
19
19
|
style?: LineLayerStyleProps;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
interface NativeProps extends Omit<LineLayerProps,
|
|
22
|
+
interface NativeProps extends Omit<LineLayerProps, "style">, NativeBaseProps {}
|
|
23
23
|
|
|
24
24
|
const RCTMLNLineLayer =
|
|
25
25
|
requireNativeComponent<NativeBaseProps>(NATIVE_MODULE_NAME);
|
|
@@ -31,7 +31,7 @@ const LineLayer: React.FC<LineLayerProps> = ({
|
|
|
31
31
|
sourceID = MapLibreGL.StyleSource.DefaultSourceID,
|
|
32
32
|
...props
|
|
33
33
|
}: LineLayerProps) => {
|
|
34
|
-
const {baseProps, setNativeLayer} = useAbstractLayer<
|
|
34
|
+
const { baseProps, setNativeLayer } = useAbstractLayer<
|
|
35
35
|
LineLayerProps,
|
|
36
36
|
NativeProps
|
|
37
37
|
>({
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import useOnce from '../hooks/useOnce';
|
|
3
|
-
import {FilterExpression} from '../utils/MaplibreStyles';
|
|
4
|
-
import {Location} from '../modules/location/locationManager';
|
|
5
|
-
import {isFunction, isAndroid} from '../utils';
|
|
6
|
-
import {getFilter} from '../utils/filterUtils';
|
|
7
|
-
import Logger from '../utils/Logger';
|
|
8
|
-
import BaseProps from '../types/BaseProps';
|
|
9
|
-
|
|
1
|
+
import debounce from "debounce";
|
|
10
2
|
import React, {
|
|
11
3
|
Component,
|
|
12
4
|
memo,
|
|
@@ -18,7 +10,7 @@ import React, {
|
|
|
18
10
|
useMemo,
|
|
19
11
|
useRef,
|
|
20
12
|
useState,
|
|
21
|
-
} from
|
|
13
|
+
} from "react";
|
|
22
14
|
import {
|
|
23
15
|
View,
|
|
24
16
|
StyleSheet,
|
|
@@ -27,22 +19,30 @@ import {
|
|
|
27
19
|
ViewProps,
|
|
28
20
|
NativeMethods,
|
|
29
21
|
NativeSyntheticEvent,
|
|
30
|
-
} from
|
|
31
|
-
|
|
22
|
+
} from "react-native";
|
|
23
|
+
|
|
24
|
+
import useNativeBridge from "../hooks/useNativeBridge";
|
|
25
|
+
import useOnce from "../hooks/useOnce";
|
|
26
|
+
import { Location } from "../modules/location/locationManager";
|
|
27
|
+
import BaseProps from "../types/BaseProps";
|
|
28
|
+
import { isFunction, isAndroid } from "../utils";
|
|
29
|
+
import Logger from "../utils/Logger";
|
|
30
|
+
import { FilterExpression } from "../utils/MaplibreStyles";
|
|
31
|
+
import { getFilter } from "../utils/filterUtils";
|
|
32
32
|
|
|
33
33
|
const MapLibreGL = NativeModules.MLNModule;
|
|
34
34
|
if (MapLibreGL == null) {
|
|
35
35
|
console.error(
|
|
36
|
-
|
|
36
|
+
"Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.",
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export const NATIVE_MODULE_NAME =
|
|
40
|
+
export const NATIVE_MODULE_NAME = "RCTMLNMapView";
|
|
41
41
|
|
|
42
|
-
export const ANDROID_TEXTURE_NATIVE_MODULE_NAME =
|
|
42
|
+
export const ANDROID_TEXTURE_NATIVE_MODULE_NAME = "RCTMLNAndroidTextureMapView";
|
|
43
43
|
|
|
44
44
|
const styles = StyleSheet.create({
|
|
45
|
-
matchParent: {flex: 1},
|
|
45
|
+
matchParent: { flex: 1 },
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
const defaultStyleURL = MapLibreGL.StyleURL.Street;
|
|
@@ -66,7 +66,7 @@ interface MapViewProps extends BaseProps {
|
|
|
66
66
|
/**
|
|
67
67
|
* Style for wrapping React Native View
|
|
68
68
|
*/
|
|
69
|
-
style?: ViewProps[
|
|
69
|
+
style?: ViewProps["style"];
|
|
70
70
|
/**
|
|
71
71
|
* Style URL for map - notice, if non is set it _will_ default to `MapLibreGL.StyleURL.Default`
|
|
72
72
|
*/
|
|
@@ -117,10 +117,10 @@ interface MapViewProps extends BaseProps {
|
|
|
117
117
|
* Adds attribution offset, e.g. `{top: 8, left: 8}` will put attribution button in top-left corner of the map
|
|
118
118
|
*/
|
|
119
119
|
attributionPosition?:
|
|
120
|
-
| {top?: number; left?: number}
|
|
121
|
-
| {top?: number; right?: number}
|
|
122
|
-
| {bottom?: number; left?: number}
|
|
123
|
-
| {bottom?: number; right?: number};
|
|
120
|
+
| { top?: number; left?: number }
|
|
121
|
+
| { top?: number; right?: number }
|
|
122
|
+
| { bottom?: number; left?: number }
|
|
123
|
+
| { bottom?: number; right?: number };
|
|
124
124
|
/**
|
|
125
125
|
* MapView's tintColor
|
|
126
126
|
*/
|
|
@@ -133,10 +133,10 @@ interface MapViewProps extends BaseProps {
|
|
|
133
133
|
* Adds logo offset, e.g. `{top: 8, left: 8}` will put the logo in top-left corner of the map
|
|
134
134
|
*/
|
|
135
135
|
logoPosition?:
|
|
136
|
-
| {top?: number; left?: number}
|
|
137
|
-
| {top?: number; right?: number}
|
|
138
|
-
| {bottom?: number; left?: number}
|
|
139
|
-
| {bottom?: number; right?: number};
|
|
136
|
+
| { top?: number; left?: number }
|
|
137
|
+
| { top?: number; right?: number }
|
|
138
|
+
| { bottom?: number; left?: number }
|
|
139
|
+
| { bottom?: number; right?: number };
|
|
140
140
|
/**
|
|
141
141
|
* Enable/Disable the compass from appearing on the map
|
|
142
142
|
*/
|
|
@@ -248,9 +248,9 @@ type CallableProps = {
|
|
|
248
248
|
: never;
|
|
249
249
|
}[keyof MapViewProps];
|
|
250
250
|
|
|
251
|
-
interface NativeProps extends Omit<MapViewProps,
|
|
252
|
-
onPress(event: NativeSyntheticEvent<{payload: GeoJSON.Feature}>): void;
|
|
253
|
-
onLongPress(event: NativeSyntheticEvent<{payload: GeoJSON.Feature}>): void;
|
|
251
|
+
interface NativeProps extends Omit<MapViewProps, "onPress" | "onLongPress"> {
|
|
252
|
+
onPress(event: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>): void;
|
|
253
|
+
onLongPress(event: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>): void;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
export interface MapViewRef {
|
|
@@ -407,8 +407,11 @@ const MapView = memo(
|
|
|
407
407
|
}),
|
|
408
408
|
);
|
|
409
409
|
|
|
410
|
-
const {
|
|
411
|
-
|
|
410
|
+
const {
|
|
411
|
+
_runNativeCommand,
|
|
412
|
+
_runPendingNativeCommands,
|
|
413
|
+
_onAndroidCallback,
|
|
414
|
+
} = useNativeBridge(NATIVE_MODULE_NAME);
|
|
412
415
|
const logger = useRef<Logger>(Logger.sharedInstance());
|
|
413
416
|
// * start the logger before anyuseEffect
|
|
414
417
|
useOnce(() => {
|
|
@@ -483,7 +486,7 @@ const MapView = memo(
|
|
|
483
486
|
}
|
|
484
487
|
|
|
485
488
|
_runNativeCommand(
|
|
486
|
-
|
|
489
|
+
"setHandledMapChangedEvents",
|
|
487
490
|
_nativeRef.current,
|
|
488
491
|
events,
|
|
489
492
|
);
|
|
@@ -493,8 +496,8 @@ const MapView = memo(
|
|
|
493
496
|
const getPointInView = async (
|
|
494
497
|
coordinate: GeoJSON.Position,
|
|
495
498
|
): Promise<GeoJSON.Point> => {
|
|
496
|
-
const res: {pointInView: GeoJSON.Point} = await _runNativeCommand(
|
|
497
|
-
|
|
499
|
+
const res: { pointInView: GeoJSON.Point } = await _runNativeCommand(
|
|
500
|
+
"getPointInView",
|
|
498
501
|
_nativeRef.current,
|
|
499
502
|
[coordinate],
|
|
500
503
|
);
|
|
@@ -504,16 +507,16 @@ const MapView = memo(
|
|
|
504
507
|
const getCoordinateFromView = async (
|
|
505
508
|
point: number[],
|
|
506
509
|
): Promise<GeoJSON.Position> => {
|
|
507
|
-
const res: {coordinateFromView: GeoJSON.Position} =
|
|
508
|
-
await _runNativeCommand(
|
|
510
|
+
const res: { coordinateFromView: GeoJSON.Position } =
|
|
511
|
+
await _runNativeCommand("getCoordinateFromView", _nativeRef.current, [
|
|
509
512
|
point,
|
|
510
513
|
]);
|
|
511
514
|
return res.coordinateFromView;
|
|
512
515
|
};
|
|
513
516
|
|
|
514
517
|
const getVisibleBounds = async (): Promise<VisibleBounds> => {
|
|
515
|
-
const res: {visibleBounds: VisibleBounds} = await _runNativeCommand(
|
|
516
|
-
|
|
518
|
+
const res: { visibleBounds: VisibleBounds } = await _runNativeCommand(
|
|
519
|
+
"getVisibleBounds",
|
|
517
520
|
_nativeRef.current,
|
|
518
521
|
);
|
|
519
522
|
return res.visibleBounds;
|
|
@@ -530,9 +533,9 @@ const MapView = memo(
|
|
|
530
533
|
);
|
|
531
534
|
}
|
|
532
535
|
|
|
533
|
-
const res: {data: string | GeoJSON.FeatureCollection} =
|
|
536
|
+
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
534
537
|
await _runNativeCommand(
|
|
535
|
-
|
|
538
|
+
"queryRenderedFeaturesAtPoint",
|
|
536
539
|
_nativeRef.current,
|
|
537
540
|
[point, getFilter(filter), layerIDs],
|
|
538
541
|
);
|
|
@@ -551,12 +554,12 @@ const MapView = memo(
|
|
|
551
554
|
): Promise<GeoJSON.FeatureCollection> => {
|
|
552
555
|
if (!bbox || bbox.length !== 4) {
|
|
553
556
|
throw new Error(
|
|
554
|
-
|
|
557
|
+
"Must pass in a valid bounding box[top, right, bottom, left]",
|
|
555
558
|
);
|
|
556
559
|
}
|
|
557
|
-
const res: {data: string | GeoJSON.FeatureCollection} =
|
|
560
|
+
const res: { data: string | GeoJSON.FeatureCollection } =
|
|
558
561
|
await _runNativeCommand(
|
|
559
|
-
|
|
562
|
+
"queryRenderedFeaturesInRect",
|
|
560
563
|
_nativeRef.current,
|
|
561
564
|
[bbox, getFilter(filter), layerIDs],
|
|
562
565
|
);
|
|
@@ -570,13 +573,13 @@ const MapView = memo(
|
|
|
570
573
|
|
|
571
574
|
const setCamera = (): void => {
|
|
572
575
|
console.warn(
|
|
573
|
-
|
|
576
|
+
"MapView.setCamera is deprecated - please use Camera#setCamera",
|
|
574
577
|
);
|
|
575
578
|
};
|
|
576
579
|
|
|
577
580
|
const takeSnap = async (writeToDisk = false): Promise<string> => {
|
|
578
|
-
const res: {uri: string} = await _runNativeCommand(
|
|
579
|
-
|
|
581
|
+
const res: { uri: string } = await _runNativeCommand(
|
|
582
|
+
"takeSnap",
|
|
580
583
|
_nativeRef.current,
|
|
581
584
|
[writeToDisk],
|
|
582
585
|
);
|
|
@@ -584,16 +587,16 @@ const MapView = memo(
|
|
|
584
587
|
};
|
|
585
588
|
|
|
586
589
|
const getZoom = async (): Promise<number> => {
|
|
587
|
-
const res: {zoom: number} = await _runNativeCommand(
|
|
588
|
-
|
|
590
|
+
const res: { zoom: number } = await _runNativeCommand(
|
|
591
|
+
"getZoom",
|
|
589
592
|
_nativeRef.current,
|
|
590
593
|
);
|
|
591
594
|
return res.zoom;
|
|
592
595
|
};
|
|
593
596
|
|
|
594
597
|
const getCenter = async (): Promise<GeoJSON.Position> => {
|
|
595
|
-
const res: {center: GeoJSON.Position} = await _runNativeCommand(
|
|
596
|
-
|
|
598
|
+
const res: { center: GeoJSON.Position } = await _runNativeCommand(
|
|
599
|
+
"getCenter",
|
|
597
600
|
_nativeRef.current,
|
|
598
601
|
);
|
|
599
602
|
return res.center;
|
|
@@ -604,7 +607,7 @@ const MapView = memo(
|
|
|
604
607
|
sourceId: string,
|
|
605
608
|
sourceLayerId: string | null = null,
|
|
606
609
|
): void => {
|
|
607
|
-
_runNativeCommand(
|
|
610
|
+
_runNativeCommand("setSourceVisibility", _nativeRef.current, [
|
|
608
611
|
visible,
|
|
609
612
|
sourceId,
|
|
610
613
|
sourceLayerId,
|
|
@@ -612,11 +615,11 @@ const MapView = memo(
|
|
|
612
615
|
};
|
|
613
616
|
|
|
614
617
|
const showAttribution = async (): Promise<void> => {
|
|
615
|
-
_runNativeCommand(
|
|
618
|
+
_runNativeCommand("showAttribution", _nativeRef.current);
|
|
616
619
|
};
|
|
617
620
|
|
|
618
621
|
const _onPress = (
|
|
619
|
-
e: NativeSyntheticEvent<{payload: GeoJSON.Feature}>,
|
|
622
|
+
e: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>,
|
|
620
623
|
): void => {
|
|
621
624
|
if (isFunction(props.onPress)) {
|
|
622
625
|
props.onPress(e.nativeEvent.payload);
|
|
@@ -624,7 +627,7 @@ const MapView = memo(
|
|
|
624
627
|
};
|
|
625
628
|
|
|
626
629
|
const _onLongPress = (
|
|
627
|
-
e: NativeSyntheticEvent<{payload: GeoJSON.Feature}>,
|
|
630
|
+
e: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>,
|
|
628
631
|
): void => {
|
|
629
632
|
if (isFunction(props.onLongPress)) {
|
|
630
633
|
props.onLongPress(e.nativeEvent.payload);
|
|
@@ -665,7 +668,7 @@ const MapView = memo(
|
|
|
665
668
|
payload?: GeoJSON.Feature | Location;
|
|
666
669
|
}>,
|
|
667
670
|
): void => {
|
|
668
|
-
const {type, payload} = e.nativeEvent;
|
|
671
|
+
const { type, payload } = e.nativeEvent;
|
|
669
672
|
let propName: CallableProps | undefined;
|
|
670
673
|
|
|
671
674
|
switch (type) {
|
|
@@ -680,11 +683,11 @@ const MapView = memo(
|
|
|
680
683
|
);
|
|
681
684
|
}
|
|
682
685
|
} else {
|
|
683
|
-
propName =
|
|
686
|
+
propName = "onRegionWillChange";
|
|
684
687
|
}
|
|
685
688
|
break;
|
|
686
689
|
case MapLibreGL.EventTypes.RegionIsChanging:
|
|
687
|
-
propName =
|
|
690
|
+
propName = "onRegionIsChanging";
|
|
688
691
|
break;
|
|
689
692
|
case MapLibreGL.EventTypes.RegionDidChange:
|
|
690
693
|
if (
|
|
@@ -697,44 +700,44 @@ const MapView = memo(
|
|
|
697
700
|
);
|
|
698
701
|
}
|
|
699
702
|
} else {
|
|
700
|
-
propName =
|
|
703
|
+
propName = "onRegionDidChange";
|
|
701
704
|
}
|
|
702
705
|
break;
|
|
703
706
|
case MapLibreGL.EventTypes.UserLocationUpdated:
|
|
704
|
-
propName =
|
|
707
|
+
propName = "onUserLocationUpdate";
|
|
705
708
|
break;
|
|
706
709
|
case MapLibreGL.EventTypes.WillStartLoadingMap:
|
|
707
|
-
propName =
|
|
710
|
+
propName = "onWillStartLoadingMap";
|
|
708
711
|
break;
|
|
709
712
|
case MapLibreGL.EventTypes.DidFinishLoadingMap:
|
|
710
|
-
propName =
|
|
713
|
+
propName = "onDidFinishLoadingMap";
|
|
711
714
|
break;
|
|
712
715
|
case MapLibreGL.EventTypes.DidFailLoadingMap:
|
|
713
|
-
propName =
|
|
716
|
+
propName = "onDidFailLoadingMap";
|
|
714
717
|
break;
|
|
715
718
|
case MapLibreGL.EventTypes.WillStartRenderingFrame:
|
|
716
|
-
propName =
|
|
719
|
+
propName = "onWillStartRenderingFrame";
|
|
717
720
|
break;
|
|
718
721
|
case MapLibreGL.EventTypes.DidFinishRenderingFrame:
|
|
719
|
-
propName =
|
|
722
|
+
propName = "onDidFinishRenderingFrame";
|
|
720
723
|
break;
|
|
721
724
|
case MapLibreGL.EventTypes.DidFinishRenderingFrameFully:
|
|
722
|
-
propName =
|
|
725
|
+
propName = "onDidFinishRenderingFrameFully";
|
|
723
726
|
break;
|
|
724
727
|
case MapLibreGL.EventTypes.WillStartRenderingMap:
|
|
725
|
-
propName =
|
|
728
|
+
propName = "onWillStartRenderingMap";
|
|
726
729
|
break;
|
|
727
730
|
case MapLibreGL.EventTypes.DidFinishRenderingMap:
|
|
728
|
-
propName =
|
|
731
|
+
propName = "onDidFinishRenderingMap";
|
|
729
732
|
break;
|
|
730
733
|
case MapLibreGL.EventTypes.DidFinishRenderingMapFully:
|
|
731
|
-
propName =
|
|
734
|
+
propName = "onDidFinishRenderingMapFully";
|
|
732
735
|
break;
|
|
733
736
|
case MapLibreGL.EventTypes.DidFinishLoadingStyle:
|
|
734
|
-
propName =
|
|
737
|
+
propName = "onDidFinishLoadingStyle";
|
|
735
738
|
break;
|
|
736
739
|
default:
|
|
737
|
-
console.warn(
|
|
740
|
+
console.warn("Unhandled event callback type", type);
|
|
738
741
|
}
|
|
739
742
|
|
|
740
743
|
if (propName) {
|
|
@@ -856,7 +859,8 @@ const MapView = memo(
|
|
|
856
859
|
<View
|
|
857
860
|
onLayout={_onLayout}
|
|
858
861
|
style={props.style}
|
|
859
|
-
testID={mapView ? undefined : props.testID}
|
|
862
|
+
testID={mapView ? undefined : props.testID}
|
|
863
|
+
>
|
|
860
864
|
{mapView}
|
|
861
865
|
</View>
|
|
862
866
|
);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import React, { ReactElement, useMemo } from "react";
|
|
2
|
+
import { Platform, requireNativeComponent, ViewProps } from "react-native";
|
|
3
3
|
|
|
4
|
-
import PointAnnotation from
|
|
4
|
+
import PointAnnotation from "./PointAnnotation";
|
|
5
|
+
import { toJSONString } from "../utils";
|
|
6
|
+
import { makePoint } from "../utils/geoUtils";
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
import {Platform, requireNativeComponent, ViewProps} from 'react-native';
|
|
8
|
-
|
|
9
|
-
export const NATIVE_MODULE_NAME = 'RCTMLNMarkerView';
|
|
8
|
+
export const NATIVE_MODULE_NAME = "RCTMLNMarkerView";
|
|
10
9
|
|
|
11
10
|
interface MarkerViewProps extends ViewProps {
|
|
12
11
|
/**
|
|
@@ -41,7 +40,7 @@ interface MarkerViewProps extends ViewProps {
|
|
|
41
40
|
|
|
42
41
|
interface NativeProps extends ViewProps {
|
|
43
42
|
coordinate: string | undefined;
|
|
44
|
-
anchor: {x: number; y: number};
|
|
43
|
+
anchor: { x: number; y: number };
|
|
45
44
|
allowOverlap: boolean;
|
|
46
45
|
isSelected: boolean;
|
|
47
46
|
}
|
|
@@ -64,7 +63,7 @@ const MarkerView = (props: MarkerViewProps): ReactElement => {
|
|
|
64
63
|
return `MV-${MarkerView.lastId}`;
|
|
65
64
|
}, []);
|
|
66
65
|
|
|
67
|
-
if (Platform.OS ===
|
|
66
|
+
if (Platform.OS === "ios") {
|
|
68
67
|
return <PointAnnotation id={idForPointAnnotation} {...props} />;
|
|
69
68
|
}
|
|
70
69
|
|
|
@@ -78,7 +77,7 @@ const MarkerView = (props: MarkerViewProps): ReactElement => {
|
|
|
78
77
|
|
|
79
78
|
MarkerView.lastId = 0;
|
|
80
79
|
MarkerView.defaultProps = {
|
|
81
|
-
anchor: {x: 0.5, y: 0.5},
|
|
80
|
+
anchor: { x: 0.5, y: 0.5 },
|
|
82
81
|
allowOverlap: false,
|
|
83
82
|
isSelected: false,
|
|
84
83
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, {ReactElement} from
|
|
2
|
-
import {requireNativeComponent} from
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
import { requireNativeComponent } from "react-native";
|
|
3
3
|
|
|
4
|
-
const NATIVE_MODULE_NAME =
|
|
4
|
+
const NATIVE_MODULE_NAME = "RCTMLNNativeUserLocation";
|
|
5
5
|
|
|
6
6
|
interface NativeUserLocationProps {
|
|
7
7
|
/**
|
|
@@ -13,7 +13,7 @@ interface NativeUserLocationProps {
|
|
|
13
13
|
*
|
|
14
14
|
* @platform android
|
|
15
15
|
*/
|
|
16
|
-
androidRenderMode?:
|
|
16
|
+
androidRenderMode?: "normal" | "compass" | "gps";
|
|
17
17
|
/**
|
|
18
18
|
* iOS only. A Boolean value indicating whether the user location annotation may display a permanent heading indicator.
|
|
19
19
|
*
|