@maplibre/maplibre-react-native 10.1.0 → 10.1.2

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 (185) hide show
  1. package/ios/MLRN/CameraStop.h +1 -1
  2. package/ios/MLRN/CameraStop.m +58 -60
  3. package/ios/MLRN/CameraUpdateItem.h +2 -1
  4. package/ios/MLRN/CameraUpdateItem.m +132 -132
  5. package/ios/MLRN/CameraUpdateQueue.m +43 -47
  6. package/ios/MLRN/FilterParser.h +1 -1
  7. package/ios/MLRN/FilterParser.m +5 -6
  8. package/ios/MLRN/MLRNBackgroundLayer.m +10 -9
  9. package/ios/MLRN/MLRNBackgroundLayerManager.m +4 -5
  10. package/ios/MLRN/MLRNCallout.h +1 -1
  11. package/ios/MLRN/MLRNCallout.m +37 -36
  12. package/ios/MLRN/MLRNCalloutManager.m +2 -3
  13. package/ios/MLRN/MLRNCamera.h +1 -1
  14. package/ios/MLRN/MLRNCamera.m +169 -182
  15. package/ios/MLRN/MLRNCameraManager.m +4 -6
  16. package/ios/MLRN/MLRNCircleLayer.m +17 -14
  17. package/ios/MLRN/MLRNCircleLayerManager.m +4 -5
  18. package/ios/MLRN/MLRNCustomHeaders.h +2 -2
  19. package/ios/MLRN/MLRNCustomHeaders.m +63 -63
  20. package/ios/MLRN/MLRNEvent.h +3 -3
  21. package/ios/MLRN/MLRNEvent.m +19 -24
  22. package/ios/MLRN/MLRNEventProtocol.h +1 -1
  23. package/ios/MLRN/MLRNFillExtrusionLayer.m +18 -14
  24. package/ios/MLRN/MLRNFillExtrusionLayerManager.m +4 -5
  25. package/ios/MLRN/MLRNFillLayer.m +16 -14
  26. package/ios/MLRN/MLRNFillLayerManager.m +4 -5
  27. package/ios/MLRN/MLRNHeatmapLayer.m +17 -14
  28. package/ios/MLRN/MLRNHeatmapLayerManager.m +4 -5
  29. package/ios/MLRN/MLRNImageQueue.h +4 -1
  30. package/ios/MLRN/MLRNImageQueue.m +29 -32
  31. package/ios/MLRN/MLRNImageQueueOperation.h +1 -1
  32. package/ios/MLRN/MLRNImageQueueOperation.m +92 -91
  33. package/ios/MLRN/MLRNImageSource.m +36 -38
  34. package/ios/MLRN/MLRNImageSourceManager.m +2 -3
  35. package/ios/MLRN/MLRNImageUtils.h +3 -3
  36. package/ios/MLRN/MLRNImageUtils.m +15 -14
  37. package/ios/MLRN/MLRNImages.h +0 -1
  38. package/ios/MLRN/MLRNImages.m +89 -91
  39. package/ios/MLRN/MLRNImagesManager.m +4 -5
  40. package/ios/MLRN/MLRNLayer.h +9 -11
  41. package/ios/MLRN/MLRNLayer.m +170 -182
  42. package/ios/MLRN/MLRNLight.m +21 -23
  43. package/ios/MLRN/MLRNLightManager.m +2 -3
  44. package/ios/MLRN/MLRNLineLayer.m +17 -15
  45. package/ios/MLRN/MLRNLineLayerManager.m +4 -6
  46. package/ios/MLRN/MLRNLocation.h +1 -1
  47. package/ios/MLRN/MLRNLocation.m +16 -17
  48. package/ios/MLRN/MLRNLocationManager.m +109 -124
  49. package/ios/MLRN/MLRNLocationManagerDelegate.h +3 -3
  50. package/ios/MLRN/MLRNLocationModule.h +1 -1
  51. package/ios/MLRN/MLRNLocationModule.m +40 -55
  52. package/ios/MLRN/MLRNLogging.h +1 -4
  53. package/ios/MLRN/MLRNLogging.m +84 -89
  54. package/ios/MLRN/MLRNMapTouchEvent.h +2 -2
  55. package/ios/MLRN/MLRNMapTouchEvent.m +50 -49
  56. package/ios/MLRN/MLRNMapView.h +43 -36
  57. package/ios/MLRN/MLRNMapView.m +409 -440
  58. package/ios/MLRN/MLRNMapViewManager.m +489 -502
  59. package/ios/MLRN/MLRNModule.h +1 -1
  60. package/ios/MLRN/MLRNModule.m +111 -105
  61. package/ios/MLRN/MLRNNativeUserLocation.m +24 -27
  62. package/ios/MLRN/MLRNNativeUserLocationManager.m +4 -8
  63. package/ios/MLRN/MLRNOfflineModule.h +1 -1
  64. package/ios/MLRN/MLRNOfflineModule.m +416 -421
  65. package/ios/MLRN/MLRNPointAnnotation.h +2 -2
  66. package/ios/MLRN/MLRNPointAnnotation.m +154 -175
  67. package/ios/MLRN/MLRNPointAnnotationManager.m +2 -3
  68. package/ios/MLRN/MLRNRasterLayer.m +16 -12
  69. package/ios/MLRN/MLRNRasterLayerManager.m +4 -5
  70. package/ios/MLRN/MLRNRasterSource.m +21 -17
  71. package/ios/MLRN/MLRNRasterSourceManager.m +2 -3
  72. package/ios/MLRN/MLRNShapeSource.h +17 -16
  73. package/ios/MLRN/MLRNShapeSource.m +94 -102
  74. package/ios/MLRN/MLRNShapeSourceManager.h +2 -2
  75. package/ios/MLRN/MLRNShapeSourceManager.m +86 -90
  76. package/ios/MLRN/MLRNSnapshotModule.h +1 -1
  77. package/ios/MLRN/MLRNSnapshotModule.m +51 -53
  78. package/ios/MLRN/MLRNSource.h +12 -12
  79. package/ios/MLRN/MLRNSource.m +82 -88
  80. package/ios/MLRN/MLRNStyleValue.h +1 -1
  81. package/ios/MLRN/MLRNStyleValue.m +128 -128
  82. package/ios/MLRN/MLRNSymbolLayer.m +17 -13
  83. package/ios/MLRN/MLRNSymbolLayerManager.m +4 -5
  84. package/ios/MLRN/MLRNTileSource.h +1 -1
  85. package/ios/MLRN/MLRNTileSource.m +21 -20
  86. package/ios/MLRN/MLRNUserLocation.h +1 -1
  87. package/ios/MLRN/MLRNUserLocation.m +10 -12
  88. package/ios/MLRN/MLRNUtils.h +18 -11
  89. package/ios/MLRN/MLRNUtils.m +168 -160
  90. package/ios/MLRN/MLRNVectorLayer.m +28 -34
  91. package/ios/MLRN/MLRNVectorSource.h +3 -1
  92. package/ios/MLRN/MLRNVectorSource.m +14 -11
  93. package/ios/MLRN/MLRNVectorSourceManager.h +2 -2
  94. package/ios/MLRN/MLRNVectorSourceManager.m +36 -39
  95. package/ios/MLRN/ViewManager.h +1 -1
  96. package/ios/MLRN/ViewManager.m +29 -35
  97. package/lib/commonjs/components/MarkerView.js +1 -1
  98. package/lib/commonjs/components/ShapeSource.js +2 -1
  99. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  100. package/lib/commonjs/components/UserLocation.js +8 -38
  101. package/lib/commonjs/components/UserLocation.js.map +1 -1
  102. package/lib/commonjs/components/UserLocationPuck.js +52 -0
  103. package/lib/commonjs/components/UserLocationPuck.js.map +1 -0
  104. package/lib/commonjs/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +12 -9
  105. package/lib/commonjs/components/UserLocationPuckHeading.js.map +1 -0
  106. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +8 -7
  107. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  108. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -2
  109. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  110. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js +28 -38
  111. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  112. package/lib/commonjs/utils/animated/AnimatedShape.js +11 -7
  113. package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
  114. package/lib/module/components/MarkerView.js +1 -1
  115. package/lib/module/components/ShapeSource.js +2 -1
  116. package/lib/module/components/ShapeSource.js.map +1 -1
  117. package/lib/module/components/UserLocation.js +7 -36
  118. package/lib/module/components/UserLocation.js.map +1 -1
  119. package/lib/module/components/UserLocationPuck.js +48 -0
  120. package/lib/module/components/UserLocationPuck.js.map +1 -0
  121. package/lib/module/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +11 -7
  122. package/lib/module/components/UserLocationPuckHeading.js.map +1 -0
  123. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +8 -7
  124. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  125. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -3
  126. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  127. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js +29 -39
  128. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  129. package/lib/module/utils/animated/AnimatedShape.js +11 -7
  130. package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
  131. package/lib/typescript/commonjs/src/components/MarkerView.d.ts +1 -1
  132. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +1 -1
  133. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/components/UserLocation.d.ts +0 -1
  135. package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts +9 -0
  137. package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts +9 -0
  139. package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
  141. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
  143. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts +0 -1
  145. package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
  147. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +8 -5
  149. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  150. package/lib/typescript/module/src/components/MarkerView.d.ts +1 -1
  151. package/lib/typescript/module/src/components/ShapeSource.d.ts +1 -1
  152. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  153. package/lib/typescript/module/src/components/UserLocation.d.ts +0 -1
  154. package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
  155. package/lib/typescript/module/src/components/UserLocationPuck.d.ts +9 -0
  156. package/lib/typescript/module/src/components/UserLocationPuck.d.ts.map +1 -0
  157. package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts +9 -0
  158. package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts.map +1 -0
  159. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
  160. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  161. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
  162. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  163. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts +0 -1
  164. package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
  165. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
  166. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  167. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +8 -5
  168. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  169. package/package.json +8 -8
  170. package/src/components/MarkerView.tsx +1 -1
  171. package/src/components/ShapeSource.tsx +58 -53
  172. package/src/components/UserLocation.tsx +13 -51
  173. package/src/components/UserLocationPuck.tsx +62 -0
  174. package/src/components/UserLocationPuckHeading.tsx +33 -0
  175. package/src/utils/animated/AbstractAnimatedCoordinates.ts +26 -15
  176. package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +10 -6
  177. package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +63 -51
  178. package/src/utils/animated/AnimatedShape.ts +22 -13
  179. package/lib/commonjs/components/HeadingIndicator.js.map +0 -1
  180. package/lib/module/components/HeadingIndicator.js.map +0 -1
  181. package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts +0 -7
  182. package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts.map +0 -1
  183. package/lib/typescript/module/src/components/HeadingIndicator.d.ts +0 -7
  184. package/lib/typescript/module/src/components/HeadingIndicator.d.ts.map +0 -1
  185. package/src/components/HeadingIndicator.tsx +0 -26
@@ -1,8 +1,8 @@
1
1
  import { Animated } from "react-native";
2
2
 
3
- // see
4
- // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js
3
+ // https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Animated/nodes/AnimatedWithChildren.js
5
4
  const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY);
5
+
6
6
  if (__DEV__) {
7
7
  if (AnimatedWithChildren.name !== "AnimatedWithChildren") {
8
8
  console.error(
@@ -19,20 +19,21 @@ const defaultConfig = {
19
19
 
20
20
  export abstract class AbstractAnimatedCoordinates<
21
21
  State,
22
+ ToValue = AnimatedCoordinates[],
22
23
  > extends AnimatedWithChildren {
23
- constructor(coords: AnimatedCoordinates[]) {
24
+ constructor(coordinates: AnimatedCoordinates[]) {
24
25
  super();
25
26
 
26
- this.state = this.onInitialState(coords);
27
+ this.state = this.onInitialState(coordinates);
27
28
  }
28
29
 
29
30
  /**
30
31
  * Subclasses can override to calculate initial state
31
32
  *
32
- * @param {AnimatedCoordinates} coordinatesArray - to value from animate
33
33
  * @returns {object} - the state object
34
+ * @param coordinates
34
35
  */
35
- abstract onInitialState(coords: AnimatedCoordinates[]): State;
36
+ abstract onInitialState(coordinates: AnimatedCoordinates[]): State;
36
37
  /**
37
38
  * Calculates state based on startingState and progress, returns a new state
38
39
  *
@@ -45,15 +46,15 @@ export abstract class AbstractAnimatedCoordinates<
45
46
  animate(
46
47
  progressValue: Animated.Value,
47
48
  progressAnimation: Animated.CompositeAnimation,
48
- config: (
49
+ config: Omit<
49
50
  | Animated.TimingAnimationConfig
50
51
  | Animated.SpringAnimationConfig
51
- | Animated.DecayAnimationConfig
52
- ) & { toValue: AnimatedCoordinates[] },
52
+ | Animated.DecayAnimationConfig,
53
+ "toValue"
54
+ > & { toValue: ToValue },
53
55
  ): Animated.CompositeAnimation {
54
56
  const onAnimationStart = (animation: Animated.CompositeAnimation): void => {
55
57
  if (this.animation) {
56
- // there was a started but not finsihed animation
57
58
  const actProgress = this.progressValue.__getValue();
58
59
  this.animation.stop();
59
60
  this.state = this.onCalculate(this.state, actProgress);
@@ -78,8 +79,11 @@ export abstract class AbstractAnimatedCoordinates<
78
79
  }
79
80
 
80
81
  timing(
81
- config: Animated.TimingAnimationConfig & {
82
- toValue: AnimatedCoordinates[];
82
+ config: Omit<
83
+ Animated.TimingAnimationConfig,
84
+ "toValue" | "useNativeDriver"
85
+ > & {
86
+ toValue: ToValue;
83
87
  },
84
88
  ): Animated.CompositeAnimation {
85
89
  const progressValue = new Animated.Value(0.0);
@@ -90,12 +94,17 @@ export abstract class AbstractAnimatedCoordinates<
90
94
  ...config,
91
95
  toValue: 1.0,
92
96
  }),
93
- config,
97
+ {
98
+ ...defaultConfig,
99
+ ...config,
100
+ },
94
101
  );
95
102
  }
96
103
 
97
104
  spring(
98
- config: Animated.SpringAnimationConfig & { toValue: AnimatedCoordinates[] },
105
+ config: Omit<Animated.SpringAnimationConfig, "toValue"> & {
106
+ toValue: ToValue;
107
+ },
99
108
  ): Animated.CompositeAnimation {
100
109
  const progressValue = new Animated.Value(0.0);
101
110
  return this.animate(
@@ -110,7 +119,9 @@ export abstract class AbstractAnimatedCoordinates<
110
119
  }
111
120
 
112
121
  decay(
113
- config: Animated.DecayAnimationConfig & { toValue: AnimatedCoordinates[] },
122
+ config: Omit<Animated.DecayAnimationConfig, "toValue"> & {
123
+ toValue: ToValue;
124
+ },
114
125
  ): Animated.CompositeAnimation {
115
126
  const progressValue = new Animated.Value(0.0);
116
127
  return this.animate(
@@ -1,8 +1,11 @@
1
1
  import { Animated } from "react-native";
2
2
 
3
- // see
4
- // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js
3
+ import type { AnimatedCoordinates } from "./AbstractAnimatedCoordinates";
4
+ import { AnimatedRouteCoordinatesArray } from "./AnimatedRouteCoordinatesArray";
5
+
6
+ // https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Animated/nodes/AnimatedWithChildren.js
5
7
  const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY);
8
+
6
9
  if (__DEV__) {
7
10
  if (AnimatedWithChildren.name !== "AnimatedWithChildren") {
8
11
  console.error(
@@ -12,24 +15,25 @@ if (__DEV__) {
12
15
  }
13
16
 
14
17
  export class AnimatedExtractCoordinateFromArray extends AnimatedWithChildren {
15
- _array: AnimatedExtractCoordinateFromArray;
18
+ _array: AnimatedRouteCoordinatesArray;
16
19
 
17
20
  _index = 0;
18
21
 
19
- constructor(array: AnimatedExtractCoordinateFromArray, index: number) {
22
+ constructor(array: AnimatedRouteCoordinatesArray, index: number) {
20
23
  super();
21
24
  this._array = array;
22
25
  this._index = index;
23
26
  }
24
27
 
25
- __getValue(): AnimatedExtractCoordinateFromArray {
28
+ __getValue(): AnimatedCoordinates {
26
29
  const actArray = this._array.__getValue();
27
30
  let index = this._index;
28
31
 
29
32
  if (index < 0) {
30
33
  index += actArray.length;
31
34
  }
32
- return actArray[index];
35
+
36
+ return actArray[index]!;
33
37
  }
34
38
 
35
39
  __attach(): void {
@@ -1,9 +1,9 @@
1
1
  import distance from "@turf/distance";
2
2
  import {
3
- lineString,
4
- point,
5
3
  convertLength,
6
4
  type Coord,
5
+ lineString,
6
+ point,
7
7
  type Units,
8
8
  } from "@turf/helpers";
9
9
  import length from "@turf/length";
@@ -14,6 +14,25 @@ import {
14
14
  type AnimatedCoordinates,
15
15
  } from "./AbstractAnimatedCoordinates";
16
16
 
17
+ interface AnimatedRouteToValue {
18
+ end: /**
19
+ * Animate to this point on the coordinates array
20
+ */
21
+ | { point: Coord | AnimatedCoordinates }
22
+ /**
23
+ * Animate to this length of the coordinates array
24
+ */
25
+ | {
26
+ along: number;
27
+ units?: Units;
28
+ };
29
+
30
+ /**
31
+ * @deprecated Use `end.units` in conjunction with `end.along` instead
32
+ */
33
+ units?: Units;
34
+ }
35
+
17
36
  interface AnimatedRouteState {
18
37
  actRoute?: AnimatedCoordinates[];
19
38
  fullRoute: AnimatedCoordinates[];
@@ -21,66 +40,65 @@ interface AnimatedRouteState {
21
40
  from: number;
22
41
  current?: number;
23
42
  to: number;
24
- point?: Coord;
25
- along?: Coord;
26
- };
43
+ } & ({ point?: Coord | AnimatedCoordinates } | { along?: number });
27
44
  }
28
45
 
29
- export class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoordinates<AnimatedRouteState> {
46
+ export class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoordinates<
47
+ AnimatedRouteState,
48
+ AnimatedRouteToValue
49
+ > {
30
50
  /**
31
51
  * Calculate initial state
32
52
  *
33
- * @param {*} args - to value from animate
34
- * @returns {object} - the state object
53
+ * @param {AnimatedCoordinates[]} coordinatesArray
54
+ * @returns {AnimatedRouteState}
35
55
  */
36
56
  onInitialState(coordinatesArray: AnimatedCoordinates[]): AnimatedRouteState {
37
57
  return {
38
58
  fullRoute: coordinatesArray.map(
39
- (coord): AnimatedCoordinates => [coord[0], coord[1]],
59
+ (coordinates): AnimatedCoordinates => [coordinates[0], coordinates[1]],
40
60
  ),
41
61
  end: { from: 0, to: 0 },
42
62
  };
43
63
  }
44
64
 
45
65
  /**
46
- * Calculate value from state.
66
+ * Calculate value from state
47
67
  *
48
- * @param {object} state - either state from initialState and/or from calculate
49
- * @returns {object}
68
+ * @param {AnimatedRouteState} state Previous state
69
+ * @returns {AnimatedCoordinates[]}
50
70
  */
51
- onGetValue(
52
- state: AnimatedRouteState,
53
- ): AnimatedRouteState | AnimatedCoordinates[] {
71
+ onGetValue(state: AnimatedRouteState): AnimatedCoordinates[] {
54
72
  return state.actRoute || state.fullRoute;
55
73
  }
56
74
 
57
75
  /**
58
76
  * Calculates state based on startingState and progress, returns a new state
59
77
  *
60
- * @param {object} state - state object from initialState and/or from calculate
61
- * @param {number} progress - value between 0 and 1
62
- * @returns {object} next state
78
+ * @param {AnimatedRouteState} state Previous state
79
+ * @param {number} progress Value between 0 and 1
80
+ * @returns {AnimatedRouteState}
63
81
  */
64
82
  onCalculate(state: AnimatedRouteState, progress: number): AnimatedRouteState {
65
83
  const { fullRoute, end } = state;
66
84
  const currentEnd = end.from * (1.0 - progress) + progress * end.to;
67
85
 
68
- let prevsum = 0;
69
- let actsum = 0;
86
+ let prevSum = 0;
87
+ let actSum = 0;
70
88
  let i = fullRoute.length - 1;
71
- while (actsum < currentEnd && i > 0) {
72
- prevsum = actsum;
89
+ while (actSum < currentEnd && i > 0) {
90
+ prevSum = actSum;
73
91
  const start = fullRoute[i];
74
92
  const end = fullRoute[i - 1];
75
- actsum +=
93
+ actSum +=
76
94
  start && end ? distance(point(start), point(end), this.distconf) : 0;
77
95
  i -= 1;
78
96
  }
79
- if (actsum <= currentEnd) {
97
+ if (actSum <= currentEnd) {
80
98
  const actRoute = [...fullRoute.slice(0, i + 1)];
81
99
  return { fullRoute, end: { ...end, current: currentEnd }, actRoute };
82
100
  }
83
- const r = (currentEnd - prevsum) / (actsum - prevsum);
101
+ const r = (currentEnd - prevSum) / (actSum - prevSum);
84
102
  const or = 1.0 - r;
85
103
 
86
104
  const actRoute = [
@@ -96,53 +114,47 @@ export class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoordinates<A
96
114
  /**
97
115
  * Subclasses can override to start a new animation
98
116
  *
117
+ * @param {AnimatedRouteState} state
99
118
  * @param {*} toValue - to value from animate
100
- * @param {*} actCoords - the current coordinates array to start from
101
119
  * @returns {object} The state
102
120
  */
103
121
  onStart(
104
122
  state: AnimatedRouteState,
105
- toValue: { end: { point?: Coord; along?: number }; units?: Units },
123
+ toValue: AnimatedRouteToValue,
106
124
  ): AnimatedRouteState {
107
125
  const { fullRoute, end } = state;
108
- let toDist = 0;
109
- if (!toValue.end) {
110
- console.error(
111
- "RouteCoordinatesArray: toValue should have end with either along or point",
112
- );
113
- }
114
- if (toValue.end.along) {
126
+ const fullRouteLineString = lineString(fullRoute);
127
+
128
+ let to: number | undefined = undefined;
129
+
130
+ if ("along" in toValue.end) {
115
131
  const { units } = toValue;
116
- const ls = lineString(fullRoute);
117
- toDist = convertLength(toValue.end.along, units);
118
- toDist = length(ls) - toDist;
119
- }
120
- if (toDist != null) {
121
- if (toValue.end.point) {
132
+
133
+ if (units !== undefined) {
122
134
  console.warn(
123
- "RouteCoordinatesArray: toValue.end: has both along and point, point is ignored",
135
+ "RouteCoordinatesArray: `toValue.units` is deprecated, use `toValue.end.units` instead.",
124
136
  );
125
137
  }
126
- } else if (toValue.end.point) {
127
- const ls = lineString(fullRoute);
128
138
 
129
- const nearest = nearestPointOnLine(ls, toValue.end.point);
130
- toDist = length(ls) - nearest.properties.location!;
139
+ to =
140
+ length(fullRouteLineString) -
141
+ convertLength(toValue.end.along, toValue.end.units ?? units);
131
142
  } else {
132
- console.warn(
133
- "RouteCoordinatesArray: toValue.end: should have either along or point",
143
+ const nearest = nearestPointOnLine(
144
+ fullRouteLineString,
145
+ toValue.end.point,
134
146
  );
147
+ to = length(fullRouteLineString) - nearest.properties.location!;
135
148
  }
136
149
 
137
- const result = {
150
+ return {
138
151
  fullRoute,
139
152
  end: {
140
153
  ...end,
141
- from: end.current != null ? end.current : end.from,
142
- to: toDist,
154
+ from: end.current ?? end.from,
155
+ to,
143
156
  },
144
157
  };
145
- return result;
146
158
  }
147
159
 
148
160
  get originalRoute(): AnimatedCoordinates[] {
@@ -2,13 +2,13 @@
2
2
 
3
3
  import { Animated } from "react-native";
4
4
 
5
- import { AnimatedCoordinatesArray } from "./AnimatedCoordinatesArray";
5
+ import type { AnimatedCoordinatesArray } from "./AnimatedCoordinatesArray";
6
6
  import { AnimatedExtractCoordinateFromArray } from "./AnimatedExtractCoordinateFromArray";
7
7
  import { AnimatedRouteCoordinatesArray } from "./AnimatedRouteCoordinatesArray";
8
8
 
9
- // see
10
- // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js
9
+ // https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Animated/nodes/AnimatedWithChildren.js
11
10
  const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY);
11
+
12
12
  if (__DEV__) {
13
13
  if (AnimatedWithChildren.name !== "AnimatedWithChildren") {
14
14
  console.error(
@@ -20,24 +20,23 @@ if (__DEV__) {
20
20
  type Shape =
21
21
  | {
22
22
  type: "Point";
23
- coordinates:
24
- | AnimatedExtractCoordinateFromArray
25
- | AnimatedRouteCoordinatesArray;
23
+ coordinates: AnimatedExtractCoordinateFromArray;
26
24
  }
27
25
  | {
28
26
  type: "LineString";
29
- coordinates: AnimatedCoordinatesArray;
27
+ coordinates: AnimatedCoordinatesArray | AnimatedRouteCoordinatesArray;
30
28
  };
31
29
 
32
30
  /**
33
31
  * AnimatedShape can be used to have animated properties inside the shape property
32
+ *
33
+ * Equivalent of AnimatedStyle for shapes
34
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Animated/nodes/AnimatedStyle.js
35
+ *
34
36
  * @example
35
37
  * <AnimatedShapeSource ... shape={new AnimatedShape({type:'LineString', coordinates: animatedCoords})} />
36
38
  */
37
39
  export class AnimatedShape extends AnimatedWithChildren {
38
- // equivalent of AnimatedStyle for shapes
39
- // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedStyle.js
40
-
41
40
  constructor(shape: Shape) {
42
41
  super();
43
42
  this.shape = shape;
@@ -47,23 +46,33 @@ export class AnimatedShape extends AnimatedWithChildren {
47
46
  if (Array.isArray(value)) {
48
47
  return value.map((i) => this._walkShapeAndGetValues(i));
49
48
  }
49
+
50
50
  // @ts-expect-error Animated.Node is not exported
51
51
  if (value instanceof Animated.Node) {
52
52
  return (value as any).__getValue();
53
53
  }
54
+
54
55
  if (typeof value === "object") {
55
56
  const result: { [key: string]: any } = {};
57
+
56
58
  for (const key in value) {
57
59
  result[key] = this._walkShapeAndGetValues(value[key]);
58
60
  }
61
+
59
62
  return result;
60
63
  }
64
+
61
65
  return value;
62
66
  }
63
67
 
64
- __getValue(): any {
65
- const result = this._walkShapeAndGetValues(this.shape);
66
- return result;
68
+ __getValue(): GeoJSON.Point | GeoJSON.LineString {
69
+ const shape = this._walkShapeAndGetValues(this.shape);
70
+
71
+ if (shape.type === "LineString" && shape.coordinates.length === 1) {
72
+ shape.coordinates = [...shape.coordinates, ...shape.coordinates];
73
+ }
74
+
75
+ return shape;
67
76
  }
68
77
 
69
78
  // @ts-expect-error Animated.Node is not exported
@@ -1 +0,0 @@
1
- {"version":3,"names":["_SymbolLayer","require","_heading","_interopRequireDefault","_jsxRuntime","e","__esModule","default","style","iconImage","headingIcon","iconAllowOverlap","iconPitchAlignment","iconRotationAlignment","HeadingIndicator","heading","jsx","SymbolLayer","id","belowLayerID","iconRotate","exports"],"sourceRoot":"../../../src","sources":["components/HeadingIndicator.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAgD,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGhD,MAAMG,KAAK,GAAG;EACZC,SAAS,EAAEC,gBAAW;EACtBC,gBAAgB,EAAE,IAAI;EACtBC,kBAAkB,EAAE,KAAK;EACzBC,qBAAqB,EAAE;AACzB,CAAU;AAMH,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC;AAA+B,CAAC,kBACjE,IAAAX,WAAA,CAAAY,GAAA,EAAChB,YAAA,CAAAiB,WAAW;EAEVC,EAAE,EAAC,oCAAoC;EACvCC,YAAY,EAAC,+BAA+B;EAC5CX,KAAK,EAAE;IACLY,UAAU,EAAEL,OAAO;IACnB,GAAGP;EACL;AAAE,GANE,oCAOL,CACF;AAACa,OAAA,CAAAP,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["SymbolLayer","headingIcon","jsx","_jsx","style","iconImage","iconAllowOverlap","iconPitchAlignment","iconRotationAlignment","HeadingIndicator","heading","id","belowLayerID","iconRotate"],"sourceRoot":"../../../src","sources":["components/HeadingIndicator.tsx"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,kBAAe;AAC3C,OAAOC,WAAW,MAAM,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGhD,MAAMC,KAAK,GAAG;EACZC,SAAS,EAAEJ,WAAW;EACtBK,gBAAgB,EAAE,IAAI;EACtBC,kBAAkB,EAAE,KAAK;EACzBC,qBAAqB,EAAE;AACzB,CAAU;AAMV,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC;AAA+B,CAAC,kBACjEP,IAAA,CAACH,WAAW;EAEVW,EAAE,EAAC,oCAAoC;EACvCC,YAAY,EAAC,+BAA+B;EAC5CR,KAAK,EAAE;IACLS,UAAU,EAAEH,OAAO;IACnB,GAAGN;EACL;AAAE,GANE,oCAOL,CACF","ignoreList":[]}
@@ -1,7 +0,0 @@
1
- import { type BaseProps } from "../types/BaseProps";
2
- interface HeadingIndicatorProps extends BaseProps {
3
- heading?: number;
4
- }
5
- export declare const HeadingIndicator: ({ heading }: HeadingIndicatorProps) => import("react/jsx-runtime").JSX.Element;
6
- export {};
7
- //# sourceMappingURL=HeadingIndicator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HeadingIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/components/HeadingIndicator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AASpD,UAAU,qBAAsB,SAAQ,SAAS;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,gBAAgB,gBAAiB,qBAAqB,4CAUlE,CAAC"}
@@ -1,7 +0,0 @@
1
- import { type BaseProps } from "../types/BaseProps";
2
- interface HeadingIndicatorProps extends BaseProps {
3
- heading?: number;
4
- }
5
- export declare const HeadingIndicator: ({ heading }: HeadingIndicatorProps) => import("react/jsx-runtime").JSX.Element;
6
- export {};
7
- //# sourceMappingURL=HeadingIndicator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HeadingIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/components/HeadingIndicator.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AASpD,UAAU,qBAAsB,SAAQ,SAAS;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,gBAAgB,gBAAiB,qBAAqB,4CAUlE,CAAC"}
@@ -1,26 +0,0 @@
1
- import { SymbolLayer } from "./SymbolLayer";
2
- import headingIcon from "../assets/heading.png";
3
- import { type BaseProps } from "../types/BaseProps";
4
-
5
- const style = {
6
- iconImage: headingIcon,
7
- iconAllowOverlap: true,
8
- iconPitchAlignment: "map",
9
- iconRotationAlignment: "map",
10
- } as const;
11
-
12
- interface HeadingIndicatorProps extends BaseProps {
13
- heading?: number;
14
- }
15
-
16
- export const HeadingIndicator = ({ heading }: HeadingIndicatorProps) => (
17
- <SymbolLayer
18
- key="mapboxUserLocationHeadingIndicator"
19
- id="mapboxUserLocationHeadingIndicator"
20
- belowLayerID="mapboxUserLocationWhiteCircle"
21
- style={{
22
- iconRotate: heading,
23
- ...style,
24
- }}
25
- />
26
- );