@maplibre/maplibre-react-native 10.0.0-alpha.8 → 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 +6 -0
- package/README.md +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/.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,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
|
*
|
|
@@ -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
|