@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.
Files changed (131) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraModule.kt +65 -2
  3. package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt +7 -5
  4. package/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXCameraModuleSpec.java +8 -0
  5. package/ios/RNMBX/RNMBXCamera.swift +64 -3
  6. package/ios/RNMBX/RNMBXCameraModule.mm +26 -1
  7. package/ios/install.md +1 -1
  8. package/lib/commonjs/components/Camera.js +29 -1
  9. package/lib/commonjs/components/Camera.js.map +1 -1
  10. package/lib/commonjs/modules/location/locationManager.js +3 -1
  11. package/lib/commonjs/modules/location/locationManager.js.map +1 -1
  12. package/lib/commonjs/plugin/build/generateCode.js +5 -6
  13. package/lib/commonjs/plugin/install.md +2 -2
  14. package/lib/commonjs/specs/NativeRNMBXCameraModule.ts +16 -3
  15. package/lib/module/components/Camera.js +29 -1
  16. package/lib/module/components/Camera.js.map +1 -1
  17. package/lib/module/modules/location/locationManager.js +3 -1
  18. package/lib/module/modules/location/locationManager.js.map +1 -1
  19. package/lib/module/specs/NativeRNMBXCameraModule.ts +16 -3
  20. package/lib/typescript/src/Mapbox.d.ts +0 -1
  21. package/lib/typescript/src/Mapbox.d.ts.map +1 -1
  22. package/lib/typescript/src/RNMBXModule.d.ts +1 -1
  23. package/lib/typescript/src/RNMBXModule.d.ts.map +1 -1
  24. package/lib/typescript/src/components/AbstractLayer.d.ts.map +1 -1
  25. package/lib/typescript/src/components/Camera.d.ts +20 -0
  26. package/lib/typescript/src/components/Camera.d.ts.map +1 -1
  27. package/lib/typescript/src/components/HeadingIndicator.d.ts.map +1 -1
  28. package/lib/typescript/src/components/Light.d.ts.map +1 -1
  29. package/lib/typescript/src/components/MapView.d.ts +4 -3
  30. package/lib/typescript/src/components/MapView.d.ts.map +1 -1
  31. package/lib/typescript/src/components/NativeBridgeComponent.d.ts +4 -4
  32. package/lib/typescript/src/components/NativeBridgeComponent.d.ts.map +1 -1
  33. package/lib/typescript/src/components/PointAnnotation.d.ts +4 -3
  34. package/lib/typescript/src/components/PointAnnotation.d.ts.map +1 -1
  35. package/lib/typescript/src/components/ShapeSource.d.ts +4 -3
  36. package/lib/typescript/src/components/ShapeSource.d.ts.map +1 -1
  37. package/lib/typescript/src/components/Style.d.ts.map +1 -1
  38. package/lib/typescript/src/modules/location/locationManager.d.ts.map +1 -1
  39. package/lib/typescript/src/specs/NativeMapViewModule.d.ts +0 -1
  40. package/lib/typescript/src/specs/NativeMapViewModule.d.ts.map +1 -1
  41. package/lib/typescript/src/specs/NativeRNMBXCameraModule.d.ts +3 -3
  42. package/lib/typescript/src/specs/NativeRNMBXCameraModule.d.ts.map +1 -1
  43. package/lib/typescript/src/specs/NativeRNMBXChangeLineOffsetsShapeAnimatorModule.d.ts +0 -1
  44. package/lib/typescript/src/specs/NativeRNMBXChangeLineOffsetsShapeAnimatorModule.d.ts.map +1 -1
  45. package/lib/typescript/src/specs/NativeRNMBXImageModule.d.ts +0 -1
  46. package/lib/typescript/src/specs/NativeRNMBXImageModule.d.ts.map +1 -1
  47. package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts +0 -1
  48. package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts.map +1 -1
  49. package/lib/typescript/src/specs/NativeRNMBXMovePointShapeAnimatorModule.d.ts +0 -1
  50. package/lib/typescript/src/specs/NativeRNMBXMovePointShapeAnimatorModule.d.ts.map +1 -1
  51. package/lib/typescript/src/specs/NativeRNMBXPointAnnotationModule.d.ts +0 -1
  52. package/lib/typescript/src/specs/NativeRNMBXPointAnnotationModule.d.ts.map +1 -1
  53. package/lib/typescript/src/specs/NativeRNMBXShapeSourceModule.d.ts +0 -1
  54. package/lib/typescript/src/specs/NativeRNMBXShapeSourceModule.d.ts.map +1 -1
  55. package/lib/typescript/src/specs/NativeRNMBXTileStoreModule.d.ts +0 -1
  56. package/lib/typescript/src/specs/NativeRNMBXTileStoreModule.d.ts.map +1 -1
  57. package/lib/typescript/src/specs/NativeRNMBXViewportModule.d.ts +0 -1
  58. package/lib/typescript/src/specs/NativeRNMBXViewportModule.d.ts.map +1 -1
  59. package/lib/typescript/src/specs/RNMBXAtmosphereNativeComponent.d.ts.map +1 -1
  60. package/lib/typescript/src/specs/RNMBXBackgroundLayerNativeComponent.d.ts +0 -1
  61. package/lib/typescript/src/specs/RNMBXBackgroundLayerNativeComponent.d.ts.map +1 -1
  62. package/lib/typescript/src/specs/RNMBXCalloutNativeComponent.d.ts.map +1 -1
  63. package/lib/typescript/src/specs/RNMBXCameraNativeComponent.d.ts +0 -1
  64. package/lib/typescript/src/specs/RNMBXCameraNativeComponent.d.ts.map +1 -1
  65. package/lib/typescript/src/specs/RNMBXCircleLayerNativeComponent.d.ts +0 -1
  66. package/lib/typescript/src/specs/RNMBXCircleLayerNativeComponent.d.ts.map +1 -1
  67. package/lib/typescript/src/specs/RNMBXCustomLocationProviderNativeComponent.d.ts +0 -1
  68. package/lib/typescript/src/specs/RNMBXCustomLocationProviderNativeComponent.d.ts.map +1 -1
  69. package/lib/typescript/src/specs/RNMBXFillExtrusionLayerNativeComponent.d.ts +0 -1
  70. package/lib/typescript/src/specs/RNMBXFillExtrusionLayerNativeComponent.d.ts.map +1 -1
  71. package/lib/typescript/src/specs/RNMBXFillLayerNativeComponent.d.ts +0 -1
  72. package/lib/typescript/src/specs/RNMBXFillLayerNativeComponent.d.ts.map +1 -1
  73. package/lib/typescript/src/specs/RNMBXHeatmapLayerNativeComponent.d.ts +0 -1
  74. package/lib/typescript/src/specs/RNMBXHeatmapLayerNativeComponent.d.ts.map +1 -1
  75. package/lib/typescript/src/specs/RNMBXImageNativeComponent.d.ts +0 -1
  76. package/lib/typescript/src/specs/RNMBXImageNativeComponent.d.ts.map +1 -1
  77. package/lib/typescript/src/specs/RNMBXImageSourceNativeComponent.d.ts.map +1 -1
  78. package/lib/typescript/src/specs/RNMBXImagesNativeComponent.d.ts +0 -1
  79. package/lib/typescript/src/specs/RNMBXImagesNativeComponent.d.ts.map +1 -1
  80. package/lib/typescript/src/specs/RNMBXLightNativeComponent.d.ts.map +1 -1
  81. package/lib/typescript/src/specs/RNMBXLineLayerNativeComponent.d.ts +0 -1
  82. package/lib/typescript/src/specs/RNMBXLineLayerNativeComponent.d.ts.map +1 -1
  83. package/lib/typescript/src/specs/RNMBXMapViewNativeComponent.d.ts +0 -1
  84. package/lib/typescript/src/specs/RNMBXMapViewNativeComponent.d.ts.map +1 -1
  85. package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts.map +1 -1
  86. package/lib/typescript/src/specs/RNMBXMarkerViewNativeComponent.d.ts +0 -1
  87. package/lib/typescript/src/specs/RNMBXMarkerViewNativeComponent.d.ts.map +1 -1
  88. package/lib/typescript/src/specs/RNMBXModelLayerNativeComponent.d.ts +0 -1
  89. package/lib/typescript/src/specs/RNMBXModelLayerNativeComponent.d.ts.map +1 -1
  90. package/lib/typescript/src/specs/RNMBXModelsNativeComponent.d.ts.map +1 -1
  91. package/lib/typescript/src/specs/RNMBXNativeUserLocationNativeComponent.d.ts.map +1 -1
  92. package/lib/typescript/src/specs/RNMBXPointAnnotationNativeComponent.d.ts +0 -1
  93. package/lib/typescript/src/specs/RNMBXPointAnnotationNativeComponent.d.ts.map +1 -1
  94. package/lib/typescript/src/specs/RNMBXRasterDemSourceNativeComponent.d.ts +0 -1
  95. package/lib/typescript/src/specs/RNMBXRasterDemSourceNativeComponent.d.ts.map +1 -1
  96. package/lib/typescript/src/specs/RNMBXRasterLayerNativeComponent.d.ts +0 -1
  97. package/lib/typescript/src/specs/RNMBXRasterLayerNativeComponent.d.ts.map +1 -1
  98. package/lib/typescript/src/specs/RNMBXRasterSourceNativeComponent.d.ts +0 -1
  99. package/lib/typescript/src/specs/RNMBXRasterSourceNativeComponent.d.ts.map +1 -1
  100. package/lib/typescript/src/specs/RNMBXShapeSourceNativeComponent.d.ts +0 -1
  101. package/lib/typescript/src/specs/RNMBXShapeSourceNativeComponent.d.ts.map +1 -1
  102. package/lib/typescript/src/specs/RNMBXSkyLayerNativeComponent.d.ts +0 -1
  103. package/lib/typescript/src/specs/RNMBXSkyLayerNativeComponent.d.ts.map +1 -1
  104. package/lib/typescript/src/specs/RNMBXStyleImportNativeComponent.d.ts.map +1 -1
  105. package/lib/typescript/src/specs/RNMBXSymbolLayerNativeComponent.d.ts +0 -1
  106. package/lib/typescript/src/specs/RNMBXSymbolLayerNativeComponent.d.ts.map +1 -1
  107. package/lib/typescript/src/specs/RNMBXTerrainNativeComponent.d.ts.map +1 -1
  108. package/lib/typescript/src/specs/RNMBXVectorSourceNativeComponent.d.ts +0 -1
  109. package/lib/typescript/src/specs/RNMBXVectorSourceNativeComponent.d.ts.map +1 -1
  110. package/lib/typescript/src/specs/RNMBXViewportNativeComponent.d.ts +0 -1
  111. package/lib/typescript/src/specs/RNMBXViewportNativeComponent.d.ts.map +1 -1
  112. package/lib/typescript/src/specs/codegenUtils.d.ts +1 -2
  113. package/lib/typescript/src/specs/codegenUtils.d.ts.map +1 -1
  114. package/lib/typescript/src/utils/BridgeValue.d.ts.map +1 -1
  115. package/lib/typescript/src/utils/NativeCommands.d.ts +0 -1
  116. package/lib/typescript/src/utils/NativeCommands.d.ts.map +1 -1
  117. package/lib/typescript/src/utils/getAnnotationsLayerID.d.ts +1 -1
  118. package/lib/typescript/src/utils/getAnnotationsLayerID.d.ts.map +1 -1
  119. package/lib/typescript/src/web/MapContext.d.ts +1 -1
  120. package/lib/typescript/src/web/MapContext.d.ts.map +1 -1
  121. package/lib/typescript/src/web/components/Camera.d.ts +2 -2
  122. package/lib/typescript/src/web/components/Camera.d.ts.map +1 -1
  123. package/package.json +3 -3
  124. package/plugin/build/generateCode.js +5 -6
  125. package/plugin/install.md +2 -2
  126. package/rnmapbox-maps.podspec +1 -1
  127. package/src/components/Camera.tsx +83 -1
  128. package/src/modules/location/locationManager.ts +3 -1
  129. package/src/specs/NativeRNMBXCameraModule.ts +16 -3
  130. package/src/specs/codegenUtils.ts +1 -1
  131. 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 NativeAnimationMode = 'flight' | 'ease' | 'linear' | 'none' | 'move';
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?: NativeAnimationMode;
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');
@@ -25,5 +25,5 @@ export type NativeCameraStop = {
25
25
  paddingTop?: Double;
26
26
  paddingBottom?: Double;
27
27
  duration?: Double;
28
- mode?: string;
28
+ mode?: number;
29
29
  } | null;
@@ -52,7 +52,7 @@ class Camera
52
52
  'centerCoordinate' | 'zoomLevel' | 'minZoomLevel' | 'maxZoomLevel'
53
53
  >
54
54
  >
55
- implements Omit<CameraRef, 'setCamera'>
55
+ implements Omit<CameraRef, 'setCamera' | 'moveBy' | 'scaleBy'>
56
56
  {
57
57
  context!: ContextType<typeof MapContext>;
58
58