@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.
- package/ios/MLRN/CameraStop.h +1 -1
- package/ios/MLRN/CameraStop.m +58 -60
- package/ios/MLRN/CameraUpdateItem.h +2 -1
- package/ios/MLRN/CameraUpdateItem.m +132 -132
- package/ios/MLRN/CameraUpdateQueue.m +43 -47
- package/ios/MLRN/FilterParser.h +1 -1
- package/ios/MLRN/FilterParser.m +5 -6
- package/ios/MLRN/MLRNBackgroundLayer.m +10 -9
- package/ios/MLRN/MLRNBackgroundLayerManager.m +4 -5
- package/ios/MLRN/MLRNCallout.h +1 -1
- package/ios/MLRN/MLRNCallout.m +37 -36
- package/ios/MLRN/MLRNCalloutManager.m +2 -3
- package/ios/MLRN/MLRNCamera.h +1 -1
- package/ios/MLRN/MLRNCamera.m +169 -182
- package/ios/MLRN/MLRNCameraManager.m +4 -6
- package/ios/MLRN/MLRNCircleLayer.m +17 -14
- package/ios/MLRN/MLRNCircleLayerManager.m +4 -5
- package/ios/MLRN/MLRNCustomHeaders.h +2 -2
- package/ios/MLRN/MLRNCustomHeaders.m +63 -63
- package/ios/MLRN/MLRNEvent.h +3 -3
- package/ios/MLRN/MLRNEvent.m +19 -24
- package/ios/MLRN/MLRNEventProtocol.h +1 -1
- package/ios/MLRN/MLRNFillExtrusionLayer.m +18 -14
- package/ios/MLRN/MLRNFillExtrusionLayerManager.m +4 -5
- package/ios/MLRN/MLRNFillLayer.m +16 -14
- package/ios/MLRN/MLRNFillLayerManager.m +4 -5
- package/ios/MLRN/MLRNHeatmapLayer.m +17 -14
- package/ios/MLRN/MLRNHeatmapLayerManager.m +4 -5
- package/ios/MLRN/MLRNImageQueue.h +4 -1
- package/ios/MLRN/MLRNImageQueue.m +29 -32
- package/ios/MLRN/MLRNImageQueueOperation.h +1 -1
- package/ios/MLRN/MLRNImageQueueOperation.m +92 -91
- package/ios/MLRN/MLRNImageSource.m +36 -38
- package/ios/MLRN/MLRNImageSourceManager.m +2 -3
- package/ios/MLRN/MLRNImageUtils.h +3 -3
- package/ios/MLRN/MLRNImageUtils.m +15 -14
- package/ios/MLRN/MLRNImages.h +0 -1
- package/ios/MLRN/MLRNImages.m +89 -91
- package/ios/MLRN/MLRNImagesManager.m +4 -5
- package/ios/MLRN/MLRNLayer.h +9 -11
- package/ios/MLRN/MLRNLayer.m +170 -182
- package/ios/MLRN/MLRNLight.m +21 -23
- package/ios/MLRN/MLRNLightManager.m +2 -3
- package/ios/MLRN/MLRNLineLayer.m +17 -15
- package/ios/MLRN/MLRNLineLayerManager.m +4 -6
- package/ios/MLRN/MLRNLocation.h +1 -1
- package/ios/MLRN/MLRNLocation.m +16 -17
- package/ios/MLRN/MLRNLocationManager.m +109 -124
- package/ios/MLRN/MLRNLocationManagerDelegate.h +3 -3
- package/ios/MLRN/MLRNLocationModule.h +1 -1
- package/ios/MLRN/MLRNLocationModule.m +40 -55
- package/ios/MLRN/MLRNLogging.h +1 -4
- package/ios/MLRN/MLRNLogging.m +84 -89
- package/ios/MLRN/MLRNMapTouchEvent.h +2 -2
- package/ios/MLRN/MLRNMapTouchEvent.m +50 -49
- package/ios/MLRN/MLRNMapView.h +43 -36
- package/ios/MLRN/MLRNMapView.m +409 -440
- package/ios/MLRN/MLRNMapViewManager.m +489 -502
- package/ios/MLRN/MLRNModule.h +1 -1
- package/ios/MLRN/MLRNModule.m +111 -105
- package/ios/MLRN/MLRNNativeUserLocation.m +24 -27
- package/ios/MLRN/MLRNNativeUserLocationManager.m +4 -8
- package/ios/MLRN/MLRNOfflineModule.h +1 -1
- package/ios/MLRN/MLRNOfflineModule.m +416 -421
- package/ios/MLRN/MLRNPointAnnotation.h +2 -2
- package/ios/MLRN/MLRNPointAnnotation.m +154 -175
- package/ios/MLRN/MLRNPointAnnotationManager.m +2 -3
- package/ios/MLRN/MLRNRasterLayer.m +16 -12
- package/ios/MLRN/MLRNRasterLayerManager.m +4 -5
- package/ios/MLRN/MLRNRasterSource.m +21 -17
- package/ios/MLRN/MLRNRasterSourceManager.m +2 -3
- package/ios/MLRN/MLRNShapeSource.h +17 -16
- package/ios/MLRN/MLRNShapeSource.m +94 -102
- package/ios/MLRN/MLRNShapeSourceManager.h +2 -2
- package/ios/MLRN/MLRNShapeSourceManager.m +86 -90
- package/ios/MLRN/MLRNSnapshotModule.h +1 -1
- package/ios/MLRN/MLRNSnapshotModule.m +51 -53
- package/ios/MLRN/MLRNSource.h +12 -12
- package/ios/MLRN/MLRNSource.m +82 -88
- package/ios/MLRN/MLRNStyleValue.h +1 -1
- package/ios/MLRN/MLRNStyleValue.m +128 -128
- package/ios/MLRN/MLRNSymbolLayer.m +17 -13
- package/ios/MLRN/MLRNSymbolLayerManager.m +4 -5
- package/ios/MLRN/MLRNTileSource.h +1 -1
- package/ios/MLRN/MLRNTileSource.m +21 -20
- package/ios/MLRN/MLRNUserLocation.h +1 -1
- package/ios/MLRN/MLRNUserLocation.m +10 -12
- package/ios/MLRN/MLRNUtils.h +18 -11
- package/ios/MLRN/MLRNUtils.m +168 -160
- package/ios/MLRN/MLRNVectorLayer.m +28 -34
- package/ios/MLRN/MLRNVectorSource.h +3 -1
- package/ios/MLRN/MLRNVectorSource.m +14 -11
- package/ios/MLRN/MLRNVectorSourceManager.h +2 -2
- package/ios/MLRN/MLRNVectorSourceManager.m +36 -39
- package/ios/MLRN/ViewManager.h +1 -1
- package/ios/MLRN/ViewManager.m +29 -35
- package/lib/commonjs/components/MarkerView.js +1 -1
- package/lib/commonjs/components/ShapeSource.js +2 -1
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/UserLocation.js +8 -38
- package/lib/commonjs/components/UserLocation.js.map +1 -1
- package/lib/commonjs/components/UserLocationPuck.js +52 -0
- package/lib/commonjs/components/UserLocationPuck.js.map +1 -0
- package/lib/commonjs/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +12 -9
- package/lib/commonjs/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +8 -7
- package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -2
- package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js +28 -38
- package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
- package/lib/commonjs/utils/animated/AnimatedShape.js +11 -7
- package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/module/components/MarkerView.js +1 -1
- package/lib/module/components/ShapeSource.js +2 -1
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/UserLocation.js +7 -36
- package/lib/module/components/UserLocation.js.map +1 -1
- package/lib/module/components/UserLocationPuck.js +48 -0
- package/lib/module/components/UserLocationPuck.js.map +1 -0
- package/lib/module/components/{HeadingIndicator.js → UserLocationPuckHeading.js} +11 -7
- package/lib/module/components/UserLocationPuckHeading.js.map +1 -0
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +8 -7
- package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -3
- package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
- package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js +29 -39
- package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
- package/lib/module/utils/animated/AnimatedShape.js +11 -7
- package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
- package/lib/typescript/commonjs/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/commonjs/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
- package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
- package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
- package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +8 -5
- package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MarkerView.d.ts +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts +0 -1
- package/lib/typescript/module/src/components/UserLocation.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuck.d.ts.map +1 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts +9 -0
- package/lib/typescript/module/src/components/UserLocationPuckHeading.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -13
- package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -4
- package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts +0 -1
- package/lib/typescript/module/src/utils/animated/AnimatedPoint.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
- package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +8 -5
- package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/MarkerView.tsx +1 -1
- package/src/components/ShapeSource.tsx +58 -53
- package/src/components/UserLocation.tsx +13 -51
- package/src/components/UserLocationPuck.tsx +62 -0
- package/src/components/UserLocationPuckHeading.tsx +33 -0
- package/src/utils/animated/AbstractAnimatedCoordinates.ts +26 -15
- package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +10 -6
- package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +63 -51
- package/src/utils/animated/AnimatedShape.ts +22 -13
- package/lib/commonjs/components/HeadingIndicator.js.map +0 -1
- package/lib/module/components/HeadingIndicator.js.map +0 -1
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/commonjs/src/components/HeadingIndicator.d.ts.map +0 -1
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts +0 -7
- package/lib/typescript/module/src/components/HeadingIndicator.d.ts.map +0 -1
- package/src/components/HeadingIndicator.tsx +0 -26
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Animated } from "react-native";
|
|
2
2
|
|
|
3
|
-
//
|
|
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(
|
|
24
|
+
constructor(coordinates: AnimatedCoordinates[]) {
|
|
24
25
|
super();
|
|
25
26
|
|
|
26
|
-
this.state = this.onInitialState(
|
|
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(
|
|
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
|
-
|
|
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:
|
|
82
|
-
|
|
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
|
-
|
|
97
|
+
{
|
|
98
|
+
...defaultConfig,
|
|
99
|
+
...config,
|
|
100
|
+
},
|
|
94
101
|
);
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
spring(
|
|
98
|
-
config: Animated.SpringAnimationConfig & {
|
|
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 & {
|
|
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
|
-
|
|
4
|
-
|
|
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:
|
|
18
|
+
_array: AnimatedRouteCoordinatesArray;
|
|
16
19
|
|
|
17
20
|
_index = 0;
|
|
18
21
|
|
|
19
|
-
constructor(array:
|
|
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():
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
along?: Coord;
|
|
26
|
-
};
|
|
43
|
+
} & ({ point?: Coord | AnimatedCoordinates } | { along?: number });
|
|
27
44
|
}
|
|
28
45
|
|
|
29
|
-
export class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoordinates<
|
|
46
|
+
export class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoordinates<
|
|
47
|
+
AnimatedRouteState,
|
|
48
|
+
AnimatedRouteToValue
|
|
49
|
+
> {
|
|
30
50
|
/**
|
|
31
51
|
* Calculate initial state
|
|
32
52
|
*
|
|
33
|
-
* @param {
|
|
34
|
-
* @returns {
|
|
53
|
+
* @param {AnimatedCoordinates[]} coordinatesArray
|
|
54
|
+
* @returns {AnimatedRouteState}
|
|
35
55
|
*/
|
|
36
56
|
onInitialState(coordinatesArray: AnimatedCoordinates[]): AnimatedRouteState {
|
|
37
57
|
return {
|
|
38
58
|
fullRoute: coordinatesArray.map(
|
|
39
|
-
(
|
|
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 {
|
|
49
|
-
* @returns {
|
|
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 {
|
|
61
|
-
* @param {number} progress
|
|
62
|
-
* @returns {
|
|
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
|
|
69
|
-
let
|
|
86
|
+
let prevSum = 0;
|
|
87
|
+
let actSum = 0;
|
|
70
88
|
let i = fullRoute.length - 1;
|
|
71
|
-
while (
|
|
72
|
-
|
|
89
|
+
while (actSum < currentEnd && i > 0) {
|
|
90
|
+
prevSum = actSum;
|
|
73
91
|
const start = fullRoute[i];
|
|
74
92
|
const end = fullRoute[i - 1];
|
|
75
|
-
|
|
93
|
+
actSum +=
|
|
76
94
|
start && end ? distance(point(start), point(end), this.distconf) : 0;
|
|
77
95
|
i -= 1;
|
|
78
96
|
}
|
|
79
|
-
if (
|
|
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 -
|
|
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:
|
|
123
|
+
toValue: AnimatedRouteToValue,
|
|
106
124
|
): AnimatedRouteState {
|
|
107
125
|
const { fullRoute, end } = state;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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.
|
|
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
|
-
|
|
130
|
-
|
|
139
|
+
to =
|
|
140
|
+
length(fullRouteLineString) -
|
|
141
|
+
convertLength(toValue.end.along, toValue.end.units ?? units);
|
|
131
142
|
} else {
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
const nearest = nearestPointOnLine(
|
|
144
|
+
fullRouteLineString,
|
|
145
|
+
toValue.end.point,
|
|
134
146
|
);
|
|
147
|
+
to = length(fullRouteLineString) - nearest.properties.location!;
|
|
135
148
|
}
|
|
136
149
|
|
|
137
|
-
|
|
150
|
+
return {
|
|
138
151
|
fullRoute,
|
|
139
152
|
end: {
|
|
140
153
|
...end,
|
|
141
|
-
from: end.current
|
|
142
|
-
to
|
|
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
|
-
//
|
|
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():
|
|
65
|
-
const
|
|
66
|
-
|
|
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
|
-
);
|