@rnmapbox/maps 10.1.39 → 10.1.40
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/android/build.gradle +1 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraModule.kt +65 -2
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt +7 -5
- package/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXCameraModuleSpec.java +8 -0
- package/ios/RNMBX/RNMBXCamera.swift +64 -3
- package/ios/RNMBX/RNMBXCameraModule.mm +26 -1
- package/ios/install.md +1 -1
- package/lib/commonjs/components/Camera.js +29 -1
- package/lib/commonjs/components/Camera.js.map +1 -1
- package/lib/commonjs/modules/location/locationManager.js +3 -1
- package/lib/commonjs/modules/location/locationManager.js.map +1 -1
- package/lib/commonjs/plugin/build/generateCode.js +5 -6
- package/lib/commonjs/plugin/install.md +2 -2
- package/lib/commonjs/specs/NativeRNMBXCameraModule.ts +16 -3
- package/lib/module/components/Camera.js +29 -1
- package/lib/module/components/Camera.js.map +1 -1
- package/lib/module/modules/location/locationManager.js +3 -1
- package/lib/module/modules/location/locationManager.js.map +1 -1
- package/lib/module/specs/NativeRNMBXCameraModule.ts +16 -3
- package/lib/typescript/src/Mapbox.d.ts +0 -1
- package/lib/typescript/src/Mapbox.d.ts.map +1 -1
- package/lib/typescript/src/RNMBXModule.d.ts +1 -1
- package/lib/typescript/src/RNMBXModule.d.ts.map +1 -1
- package/lib/typescript/src/components/AbstractLayer.d.ts.map +1 -1
- package/lib/typescript/src/components/Camera.d.ts +20 -0
- package/lib/typescript/src/components/Camera.d.ts.map +1 -1
- package/lib/typescript/src/components/HeadingIndicator.d.ts.map +1 -1
- package/lib/typescript/src/components/Light.d.ts.map +1 -1
- package/lib/typescript/src/components/MapView.d.ts +4 -3
- package/lib/typescript/src/components/MapView.d.ts.map +1 -1
- package/lib/typescript/src/components/NativeBridgeComponent.d.ts +4 -4
- package/lib/typescript/src/components/NativeBridgeComponent.d.ts.map +1 -1
- package/lib/typescript/src/components/PointAnnotation.d.ts +4 -3
- package/lib/typescript/src/components/PointAnnotation.d.ts.map +1 -1
- package/lib/typescript/src/components/ShapeSource.d.ts +4 -3
- package/lib/typescript/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/src/components/Style.d.ts.map +1 -1
- package/lib/typescript/src/modules/location/locationManager.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeMapViewModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeMapViewModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXCameraModule.d.ts +3 -3
- package/lib/typescript/src/specs/NativeRNMBXCameraModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXChangeLineOffsetsShapeAnimatorModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXChangeLineOffsetsShapeAnimatorModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXImageModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXImageModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXMovePointShapeAnimatorModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXMovePointShapeAnimatorModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXPointAnnotationModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXPointAnnotationModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXShapeSourceModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXShapeSourceModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXTileStoreModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXTileStoreModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXViewportModule.d.ts +0 -1
- package/lib/typescript/src/specs/NativeRNMBXViewportModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXAtmosphereNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXBackgroundLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXBackgroundLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXCalloutNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXCameraNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXCameraNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXCircleLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXCircleLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXCustomLocationProviderNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXCustomLocationProviderNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXFillExtrusionLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXFillExtrusionLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXFillLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXFillLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXHeatmapLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXHeatmapLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXImageNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXImageNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXImageSourceNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXImagesNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXImagesNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXLightNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXLineLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXLineLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXMapViewNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXMarkerViewNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXModelLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXModelLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXModelsNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXNativeUserLocationNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXPointAnnotationNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXPointAnnotationNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXRasterDemSourceNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXRasterDemSourceNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXRasterLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXRasterLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXRasterSourceNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXRasterSourceNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXShapeSourceNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXShapeSourceNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXSkyLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXSkyLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXStyleImportNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXSymbolLayerNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXSymbolLayerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXTerrainNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXVectorSourceNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXVectorSourceNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/RNMBXViewportNativeComponent.d.ts +0 -1
- package/lib/typescript/src/specs/RNMBXViewportNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/codegenUtils.d.ts +1 -2
- package/lib/typescript/src/specs/codegenUtils.d.ts.map +1 -1
- package/lib/typescript/src/utils/BridgeValue.d.ts.map +1 -1
- package/lib/typescript/src/utils/NativeCommands.d.ts +0 -1
- package/lib/typescript/src/utils/NativeCommands.d.ts.map +1 -1
- package/lib/typescript/src/utils/getAnnotationsLayerID.d.ts +1 -1
- package/lib/typescript/src/utils/getAnnotationsLayerID.d.ts.map +1 -1
- package/lib/typescript/src/web/MapContext.d.ts +1 -1
- package/lib/typescript/src/web/MapContext.d.ts.map +1 -1
- package/lib/typescript/src/web/components/Camera.d.ts +2 -2
- package/lib/typescript/src/web/components/Camera.d.ts.map +1 -1
- package/package.json +3 -3
- package/plugin/build/generateCode.js +5 -6
- package/plugin/install.md +2 -2
- package/rnmapbox-maps.podspec +1 -1
- package/src/components/Camera.tsx +83 -1
- package/src/modules/location/locationManager.ts +3 -1
- package/src/specs/NativeRNMBXCameraModule.ts +16 -3
- package/src/specs/codegenUtils.ts +1 -1
- package/src/web/components/Camera.tsx +1 -1
|
@@ -61,7 +61,13 @@ const nativeAnimationMode = (
|
|
|
61
61
|
|
|
62
62
|
// Native module types.
|
|
63
63
|
|
|
64
|
-
type
|
|
64
|
+
type FLIGHT = 1;
|
|
65
|
+
type EASE = 2;
|
|
66
|
+
type LINEAR = 3;
|
|
67
|
+
type MOVE = 4;
|
|
68
|
+
type NONE = 5;
|
|
69
|
+
|
|
70
|
+
type NativeAnimationMode = FLIGHT | EASE | LINEAR | MOVE | NONE;
|
|
65
71
|
|
|
66
72
|
interface NativeCameraProps extends CameraFollowConfig {
|
|
67
73
|
testID?: string;
|
|
@@ -100,6 +106,31 @@ export interface CameraRef {
|
|
|
100
106
|
flyTo: (centerCoordinate: Position, animationDuration?: number) => void;
|
|
101
107
|
moveTo: (centerCoordinate: Position, animationDuration?: number) => void;
|
|
102
108
|
zoomTo: (zoomLevel: number, animationDuration?: number) => void;
|
|
109
|
+
moveBy: (
|
|
110
|
+
props:
|
|
111
|
+
| { x: number; y: number }
|
|
112
|
+
| {
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
animationMode: 'easeTo' | 'linearTo';
|
|
116
|
+
animationDuration: number;
|
|
117
|
+
},
|
|
118
|
+
) => void;
|
|
119
|
+
scaleBy: (
|
|
120
|
+
props:
|
|
121
|
+
| {
|
|
122
|
+
x: number;
|
|
123
|
+
y: number;
|
|
124
|
+
scaleFactor: number;
|
|
125
|
+
}
|
|
126
|
+
| {
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
scaleFactor: number;
|
|
130
|
+
animationMode: 'easeTo' | 'linearTo';
|
|
131
|
+
animationDuration: number;
|
|
132
|
+
},
|
|
133
|
+
) => void;
|
|
103
134
|
}
|
|
104
135
|
|
|
105
136
|
export type CameraStop = {
|
|
@@ -520,6 +551,35 @@ export const Camera = memo(
|
|
|
520
551
|
};
|
|
521
552
|
const zoomTo = useCallback(_zoomTo, [setCamera]);
|
|
522
553
|
|
|
554
|
+
const moveBy: CameraRef['moveBy'] = useCallback(
|
|
555
|
+
(
|
|
556
|
+
moveProps,
|
|
557
|
+
) => {
|
|
558
|
+
commands.call<void>('moveBy', [
|
|
559
|
+
moveProps.x,
|
|
560
|
+
moveProps.y,
|
|
561
|
+
'animationMode' in moveProps ? nativeAnimationMode(moveProps.animationMode) : nativeAnimationMode('linearTo'),
|
|
562
|
+
'animationDuration' in moveProps ? moveProps.animationDuration : 0,
|
|
563
|
+
]);
|
|
564
|
+
},
|
|
565
|
+
[commands],
|
|
566
|
+
);
|
|
567
|
+
|
|
568
|
+
const scaleBy: CameraRef['scaleBy'] = useCallback(
|
|
569
|
+
(
|
|
570
|
+
scaleProps
|
|
571
|
+
) => {
|
|
572
|
+
commands.call<void>('scaleBy', [
|
|
573
|
+
scaleProps.x,
|
|
574
|
+
scaleProps.y,
|
|
575
|
+
'animationMode' in scaleProps ? nativeAnimationMode(scaleProps.animationMode) : nativeAnimationMode('linearTo'),
|
|
576
|
+
'animationDuration' in scaleProps ? scaleProps.animationDuration : 0,
|
|
577
|
+
scaleProps.scaleFactor,
|
|
578
|
+
]);
|
|
579
|
+
},
|
|
580
|
+
[commands],
|
|
581
|
+
);
|
|
582
|
+
|
|
523
583
|
useImperativeHandle(ref, () => ({
|
|
524
584
|
/**
|
|
525
585
|
* Sets any camera properties, with default fallbacks if unspecified.
|
|
@@ -580,6 +640,28 @@ export const Camera = memo(
|
|
|
580
640
|
* @param {number} animationDuration The transition duration
|
|
581
641
|
*/
|
|
582
642
|
zoomTo,
|
|
643
|
+
/**
|
|
644
|
+
* Move the map by a given screen coordinate offset with optional animation.
|
|
645
|
+
* Can be used to get the Android Auto (onScroll) or Carplay(mapTemplate didUpdatePanGestureWithTranslation) pan gesture applied, for these to work properly do not specify animationDuration.
|
|
646
|
+
*
|
|
647
|
+
* @param {number} x screen coordinate offset
|
|
648
|
+
* @param {number} y screen coordinate offset
|
|
649
|
+
* @param {NativeAnimationMode} animationMode mode used for the animation
|
|
650
|
+
* @param {number} animationDuration The transition duration
|
|
651
|
+
* @param {number} scaleFactor scale factor value > 0.0 and < 2.0 when 1.0 means no scaling, > 1.0 zoom in and < 1.0 zoom out
|
|
652
|
+
*/
|
|
653
|
+
moveBy,
|
|
654
|
+
/**
|
|
655
|
+
* Scale the map with optional animation.
|
|
656
|
+
* Can be used to get Android Auto pinch gesture (onScale with scaleFactor > 0.0 and < 2.0) or Android Auto double tap (onScale with scaleFactor == 2.0) applied.
|
|
657
|
+
*
|
|
658
|
+
* @param {number} x center screen coordinate
|
|
659
|
+
* @param {number} y center screen coordinate
|
|
660
|
+
* @param {number} scaleFactor scale factor value > 0.0 and < 2.0 when 1.0 means no scaling, > 1.0 zoom in and < 1.0 zoom out
|
|
661
|
+
* @param {NativeAnimationMode} animationMode mode used for the animation
|
|
662
|
+
* @param {number} animationDuration The transition duration
|
|
663
|
+
*/
|
|
664
|
+
scaleBy,
|
|
583
665
|
}));
|
|
584
666
|
|
|
585
667
|
return (
|
|
@@ -171,8 +171,10 @@ export class LocationManager {
|
|
|
171
171
|
|
|
172
172
|
if (!this._isListening) {
|
|
173
173
|
MapboxGLLocationManager.start(validDisplacement);
|
|
174
|
+
//Determine if TurboModules (new architecture) are available.
|
|
175
|
+
const isTurbo: boolean = typeof MapboxGLLocationManager.onLocationUpdate === 'function';
|
|
174
176
|
|
|
175
|
-
if (Platform.OS === 'ios') {
|
|
177
|
+
if (Platform.OS === 'ios' || !isTurbo) {
|
|
176
178
|
this.subscription = LocationModuleEventEmitter.addListener(
|
|
177
179
|
MapboxGL.LocationCallbackName.Update,
|
|
178
180
|
this._onUpdate,
|
|
@@ -15,7 +15,7 @@ interface NativeCameraStop {
|
|
|
15
15
|
paddingTop?: number;
|
|
16
16
|
paddingBottom?: number;
|
|
17
17
|
duration?: number;
|
|
18
|
-
mode?:
|
|
18
|
+
mode?: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
type Stop =
|
|
@@ -24,13 +24,26 @@ type Stop =
|
|
|
24
24
|
}
|
|
25
25
|
| NativeCameraStop;
|
|
26
26
|
|
|
27
|
-
type NativeAnimationMode = 'flight' | 'ease' | 'linear' | 'none' | 'move';
|
|
28
|
-
|
|
29
27
|
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-unused-vars
|
|
30
28
|
type ObjectOr<T> = Object;
|
|
31
29
|
|
|
32
30
|
export interface Spec extends TurboModule {
|
|
33
31
|
updateCameraStop(viewRef: ViewRef, stop: ObjectOr<Stop>): Promise<void>;
|
|
32
|
+
moveBy: (
|
|
33
|
+
viewRef: ViewRef,
|
|
34
|
+
x: number,
|
|
35
|
+
y: number,
|
|
36
|
+
animationMode: number,
|
|
37
|
+
animationDuration: number,
|
|
38
|
+
) => Promise<void>;
|
|
39
|
+
scaleBy: (
|
|
40
|
+
viewRef: ViewRef,
|
|
41
|
+
x: number,
|
|
42
|
+
y: number,
|
|
43
|
+
animationMode: number,
|
|
44
|
+
animationDuration: number,
|
|
45
|
+
scaleFactor: number,
|
|
46
|
+
) => Promise<void>;
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
export default TurboModuleRegistry.getEnforcing<Spec>('RNMBXCameraModule');
|