@lugg/maps 1.0.0-beta.4 → 1.0.0-beta.6
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/src/main/java/com/luggmaps/LuggCalloutView.kt +4 -2
- package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +4 -3
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +40 -0
- package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +31 -0
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +23 -0
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +13 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +166 -21
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +5 -0
- package/android/src/main/java/com/luggmaps/extensions/ViewExtensions.kt +11 -0
- package/ios/LuggCalloutView.h +1 -1
- package/ios/LuggCalloutView.mm +21 -11
- package/ios/LuggMapView.mm +41 -2
- package/ios/LuggMarkerView.h +3 -0
- package/ios/LuggMarkerView.mm +23 -0
- package/ios/core/AppleMapProvider.mm +236 -16
- package/ios/core/GoogleMapProvider.mm +91 -18
- package/ios/core/MapProviderDelegate.h +8 -1
- package/lib/module/MapProvider.web.js +4 -1
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +12 -1
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +21 -18
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Circle.web.js +3 -3
- package/lib/module/components/Circle.web.js.map +1 -1
- package/lib/module/components/GeoJson.js +3 -3
- package/lib/module/components/GeoJson.js.map +1 -1
- package/lib/module/components/GroundOverlay.web.js +3 -3
- package/lib/module/components/GroundOverlay.web.js.map +1 -1
- package/lib/module/components/Marker.js +17 -3
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +23 -10
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polygon.web.js +3 -3
- package/lib/module/components/Polygon.web.js.map +1 -1
- package/lib/module/components/Polyline.web.js +6 -12
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/module/components/TileOverlay.web.js +3 -3
- package/lib/module/components/TileOverlay.web.js.map +1 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/lib/module/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +3 -2
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.d.ts +1 -1
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +36 -1
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +1 -1
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Circle.web.d.ts +1 -1
- package/lib/typescript/src/components/Circle.web.d.ts.map +1 -1
- package/lib/typescript/src/components/GeoJson.d.ts +2 -1
- package/lib/typescript/src/components/GeoJson.d.ts.map +1 -1
- package/lib/typescript/src/components/GroundOverlay.web.d.ts +1 -1
- package/lib/typescript/src/components/GroundOverlay.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.d.ts +6 -3
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +14 -5
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +3 -2
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polygon.web.d.ts +1 -1
- package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/lib/typescript/src/components/TileOverlay.web.d.ts +1 -1
- package/lib/typescript/src/components/TileOverlay.web.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +1 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts +6 -1
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +8 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +1 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +0 -4
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapProvider.web.tsx +5 -3
- package/src/MapView.tsx +12 -1
- package/src/MapView.types.ts +118 -1
- package/src/MapView.web.tsx +378 -345
- package/src/components/Circle.web.tsx +81 -79
- package/src/components/GeoJson.tsx +3 -3
- package/src/components/GroundOverlay.web.tsx +65 -69
- package/src/components/Marker.tsx +28 -5
- package/src/components/Marker.types.ts +15 -5
- package/src/components/Marker.web.tsx +196 -150
- package/src/components/Polygon.web.tsx +93 -89
- package/src/components/Polyline.web.tsx +235 -235
- package/src/components/TileOverlay.web.tsx +83 -81
- package/src/components/index.ts +1 -0
- package/src/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/src/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/src/index.ts +6 -1
- package/src/index.web.ts +3 -0
- package/src/types.ts +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
1
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { useMapContext } from '../MapProvider.web';
|
|
3
3
|
import type { PolylineProps, PolylineEasing } from './Polyline.types';
|
|
4
4
|
|
|
@@ -51,270 +51,270 @@ const getGradientColor = (colors: string[], position: number): string => {
|
|
|
51
51
|
return interpolateColor(colors[index]!, colors[index + 1]!, t);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export const Polyline = (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
map,
|
|
99
|
-
colors,
|
|
100
|
-
strokeWidth,
|
|
101
|
-
hasGradient,
|
|
102
|
-
zIndex: resolvedZIndex,
|
|
103
|
-
});
|
|
104
|
-
const [mapReady, setMapReady] = useState(!!map);
|
|
105
|
-
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
propsRef.current = {
|
|
54
|
+
export const Polyline = memo(
|
|
55
|
+
({
|
|
56
|
+
coordinates,
|
|
57
|
+
strokeColors,
|
|
58
|
+
strokeWidth = 1,
|
|
59
|
+
animated,
|
|
60
|
+
animatedOptions,
|
|
61
|
+
zIndex,
|
|
62
|
+
}: PolylineProps) => {
|
|
63
|
+
const resolvedZIndex = zIndex ?? (animated ? 1 : 0);
|
|
64
|
+
const { map, isDraggingRef } = useMapContext();
|
|
65
|
+
|
|
66
|
+
const { duration, easing, trailLength, delay } = useMemo(
|
|
67
|
+
() => ({
|
|
68
|
+
duration: animatedOptions?.duration ?? DEFAULT_DURATION,
|
|
69
|
+
easing: animatedOptions?.easing ?? 'linear',
|
|
70
|
+
trailLength: Math.max(
|
|
71
|
+
0.01,
|
|
72
|
+
Math.min(1, animatedOptions?.trailLength ?? 1)
|
|
73
|
+
),
|
|
74
|
+
delay: animatedOptions?.delay ?? 0,
|
|
75
|
+
}),
|
|
76
|
+
[
|
|
77
|
+
animatedOptions?.duration,
|
|
78
|
+
animatedOptions?.easing,
|
|
79
|
+
animatedOptions?.trailLength,
|
|
80
|
+
animatedOptions?.delay,
|
|
81
|
+
]
|
|
82
|
+
);
|
|
83
|
+
const polylinesRef = useRef<google.maps.Polyline[]>([]);
|
|
84
|
+
const animationRef = useRef<number>(0);
|
|
85
|
+
|
|
86
|
+
const colors = useMemo(
|
|
87
|
+
() =>
|
|
88
|
+
strokeColors && strokeColors.length > 0
|
|
89
|
+
? (strokeColors as string[])
|
|
90
|
+
: ['#000000'],
|
|
91
|
+
[strokeColors]
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const hasGradient = colors.length > 1;
|
|
95
|
+
|
|
96
|
+
// Refs for animation loop access
|
|
97
|
+
const propsRef = useRef({
|
|
108
98
|
map,
|
|
109
99
|
colors,
|
|
110
100
|
strokeWidth,
|
|
111
101
|
hasGradient,
|
|
112
102
|
zIndex: resolvedZIndex,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const segment = existing[i];
|
|
144
|
-
if (segment) {
|
|
145
|
-
segment.setPath(segmentPath);
|
|
146
|
-
segment.setOptions({ strokeColor: color });
|
|
147
|
-
} else {
|
|
148
|
-
existing.push(
|
|
149
|
-
new google.maps.Polyline({
|
|
150
|
-
path: segmentPath,
|
|
151
|
-
strokeColor: color,
|
|
152
|
-
strokeWeight: currentStrokeWidth,
|
|
153
|
-
strokeOpacity: 1,
|
|
154
|
-
zIndex: currentZIndex,
|
|
155
|
-
map: currentMap,
|
|
156
|
-
})
|
|
157
|
-
);
|
|
103
|
+
});
|
|
104
|
+
const [mapReady, setMapReady] = useState(!!map);
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
propsRef.current = {
|
|
108
|
+
map,
|
|
109
|
+
colors,
|
|
110
|
+
strokeWidth,
|
|
111
|
+
hasGradient,
|
|
112
|
+
zIndex: resolvedZIndex,
|
|
113
|
+
};
|
|
114
|
+
if (map && !mapReady) setMapReady(true);
|
|
115
|
+
}, [map, colors, strokeWidth, hasGradient, resolvedZIndex, mapReady]);
|
|
116
|
+
|
|
117
|
+
const updatePath = useCallback((path: google.maps.LatLngLiteral[]) => {
|
|
118
|
+
const {
|
|
119
|
+
map: currentMap,
|
|
120
|
+
colors: currentColors,
|
|
121
|
+
strokeWidth: currentStrokeWidth,
|
|
122
|
+
hasGradient: currentHasGradient,
|
|
123
|
+
zIndex: currentZIndex,
|
|
124
|
+
} = propsRef.current;
|
|
125
|
+
const existing = polylinesRef.current;
|
|
126
|
+
if (!currentMap) return;
|
|
127
|
+
|
|
128
|
+
if (path.length < 2) {
|
|
129
|
+
existing.forEach((p) => p.setMap(null));
|
|
130
|
+
existing.length = 0;
|
|
131
|
+
return;
|
|
158
132
|
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Remove extra segments
|
|
162
|
-
for (let i = neededSegments; i < existing.length; i++) {
|
|
163
|
-
existing[i]?.setMap(null);
|
|
164
|
-
}
|
|
165
|
-
existing.length = neededSegments;
|
|
166
|
-
}, []);
|
|
167
|
-
|
|
168
|
-
// Cleanup on unmount
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
const polylines = polylinesRef.current;
|
|
171
|
-
return () => {
|
|
172
|
-
cancelAnimationFrame(animationRef.current);
|
|
173
|
-
polylines.forEach((p) => p.setMap(null));
|
|
174
|
-
};
|
|
175
|
-
}, []);
|
|
176
|
-
|
|
177
|
-
// Pause/resume animation during drag
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
isPausedRef.current = isDragging;
|
|
180
|
-
}, [isDragging]);
|
|
181
133
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
134
|
+
const neededSegments = currentHasGradient ? path.length - 1 : 1;
|
|
135
|
+
|
|
136
|
+
// Update or create segments
|
|
137
|
+
for (let i = 0; i < neededSegments; i++) {
|
|
138
|
+
const segmentPath = currentHasGradient
|
|
139
|
+
? [path[i]!, path[i + 1]!]
|
|
140
|
+
: path;
|
|
141
|
+
const color = currentHasGradient
|
|
142
|
+
? getGradientColor(currentColors, i / (path.length - 1))
|
|
143
|
+
: currentColors[0]!;
|
|
144
|
+
|
|
145
|
+
const segment = existing[i];
|
|
146
|
+
if (segment) {
|
|
147
|
+
segment.setPath(segmentPath);
|
|
148
|
+
segment.setOptions({ strokeColor: color });
|
|
149
|
+
} else {
|
|
150
|
+
existing.push(
|
|
151
|
+
new google.maps.Polyline({
|
|
152
|
+
path: segmentPath,
|
|
153
|
+
strokeColor: color,
|
|
154
|
+
strokeWeight: currentStrokeWidth,
|
|
155
|
+
strokeOpacity: 1,
|
|
156
|
+
zIndex: currentZIndex,
|
|
157
|
+
map: currentMap,
|
|
158
|
+
})
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
185
162
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
163
|
+
// Remove extra segments
|
|
164
|
+
for (let i = neededSegments; i < existing.length; i++) {
|
|
165
|
+
existing[i]?.setMap(null);
|
|
166
|
+
}
|
|
167
|
+
existing.length = neededSegments;
|
|
168
|
+
}, []);
|
|
169
|
+
|
|
170
|
+
// Cleanup on unmount
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
const polylines = polylinesRef.current;
|
|
173
|
+
return () => {
|
|
174
|
+
cancelAnimationFrame(animationRef.current);
|
|
175
|
+
polylines.forEach((p) => p.setMap(null));
|
|
176
|
+
};
|
|
177
|
+
}, []);
|
|
178
|
+
|
|
179
|
+
// Main effect
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (!propsRef.current.map || coordinates.length === 0) return;
|
|
182
|
+
|
|
183
|
+
const fullPath = coordinates.map((c) => ({
|
|
184
|
+
lat: c.latitude,
|
|
185
|
+
lng: c.longitude,
|
|
186
|
+
}));
|
|
190
187
|
|
|
191
|
-
|
|
188
|
+
cancelAnimationFrame(animationRef.current);
|
|
192
189
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
if (!animated) {
|
|
191
|
+
updatePath(fullPath);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
197
194
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
const totalPoints = fullPath.length;
|
|
196
|
+
const useTrailMode = trailLength < 1;
|
|
197
|
+
const renderMax = useTrailMode ? 1 : 2;
|
|
198
|
+
const cycleMax = useTrailMode ? 1 : 2.15;
|
|
202
199
|
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
let startTime: number | null = null;
|
|
201
|
+
let delayRemaining = delay;
|
|
205
202
|
|
|
206
|
-
|
|
203
|
+
let pausedAt: number | null = null;
|
|
207
204
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
205
|
+
const animate = (time: number) => {
|
|
206
|
+
if (isDraggingRef.current) {
|
|
207
|
+
if (pausedAt === null) pausedAt = time;
|
|
208
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
214
211
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
if (pausedAt !== null) {
|
|
213
|
+
if (startTime !== null) {
|
|
214
|
+
startTime += time - pausedAt;
|
|
215
|
+
}
|
|
216
|
+
pausedAt = null;
|
|
218
217
|
}
|
|
219
|
-
pausedAt = null;
|
|
220
|
-
}
|
|
221
218
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
if (startTime === null) {
|
|
220
|
+
startTime = time;
|
|
221
|
+
}
|
|
225
222
|
|
|
226
|
-
|
|
223
|
+
const elapsed = time - startTime;
|
|
227
224
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
225
|
+
if (delayRemaining > 0) {
|
|
226
|
+
if (elapsed < delayRemaining) {
|
|
227
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
startTime = time - (elapsed - delayRemaining);
|
|
231
|
+
delayRemaining = 0;
|
|
232
232
|
}
|
|
233
|
-
startTime = time - (elapsed - delayRemaining);
|
|
234
|
-
delayRemaining = 0;
|
|
235
|
-
}
|
|
236
233
|
|
|
237
|
-
|
|
234
|
+
const rawProgress = (time - startTime) / duration;
|
|
238
235
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
if (rawProgress >= cycleMax) {
|
|
237
|
+
delayRemaining = delay;
|
|
238
|
+
startTime = time;
|
|
239
|
+
}
|
|
243
240
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
241
|
+
const clampedProgress = Math.min(rawProgress, renderMax);
|
|
242
|
+
const easedProgress =
|
|
243
|
+
applyEasing(clampedProgress / renderMax, easing) * renderMax;
|
|
247
244
|
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
let startIdx: number;
|
|
246
|
+
let endIdx: number;
|
|
250
247
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
248
|
+
if (useTrailMode) {
|
|
249
|
+
endIdx = easedProgress * totalPoints;
|
|
250
|
+
startIdx = Math.max(0, endIdx - trailLength * totalPoints);
|
|
251
|
+
} else {
|
|
252
|
+
startIdx = easedProgress <= 1 ? 0 : (easedProgress - 1) * totalPoints;
|
|
253
|
+
endIdx =
|
|
254
|
+
easedProgress <= 1 ? easedProgress * totalPoints : totalPoints;
|
|
255
|
+
}
|
|
258
256
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
257
|
+
const partialPath: google.maps.LatLngLiteral[] = [];
|
|
258
|
+
const startFloor = Math.floor(startIdx);
|
|
259
|
+
const endFloor = Math.floor(endIdx);
|
|
260
|
+
|
|
261
|
+
// Start point (interpolated)
|
|
262
|
+
if (startFloor < totalPoints) {
|
|
263
|
+
const frac = startIdx - startFloor;
|
|
264
|
+
const from = fullPath[startFloor]!;
|
|
265
|
+
const to = fullPath[Math.min(startFloor + 1, totalPoints - 1)]!;
|
|
266
|
+
partialPath.push(
|
|
267
|
+
frac > 0
|
|
268
|
+
? {
|
|
269
|
+
lat: from.lat + (to.lat - from.lat) * frac,
|
|
270
|
+
lng: from.lng + (to.lng - from.lng) * frac,
|
|
271
|
+
}
|
|
272
|
+
: from
|
|
273
|
+
);
|
|
274
|
+
}
|
|
277
275
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
276
|
+
// Middle points
|
|
277
|
+
for (
|
|
278
|
+
let i = startFloor + 1;
|
|
279
|
+
i <= Math.min(endFloor, totalPoints - 1);
|
|
280
|
+
i++
|
|
281
|
+
) {
|
|
282
|
+
partialPath.push(fullPath[i]!);
|
|
283
|
+
}
|
|
286
284
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
285
|
+
// End point (interpolated)
|
|
286
|
+
if (endFloor < totalPoints - 1) {
|
|
287
|
+
const frac = endIdx - endFloor;
|
|
288
|
+
const from = fullPath[endFloor]!;
|
|
289
|
+
const to = fullPath[endFloor + 1]!;
|
|
290
|
+
if (frac > 0) {
|
|
291
|
+
partialPath.push({
|
|
292
|
+
lat: from.lat + (to.lat - from.lat) * frac,
|
|
293
|
+
lng: from.lng + (to.lng - from.lng) * frac,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
297
296
|
}
|
|
298
|
-
}
|
|
299
297
|
|
|
300
|
-
|
|
298
|
+
updatePath(partialPath);
|
|
299
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
300
|
+
};
|
|
301
|
+
|
|
301
302
|
animationRef.current = requestAnimationFrame(animate);
|
|
302
|
-
};
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
return () => cancelAnimationFrame(animationRef.current);
|
|
305
|
+
}, [
|
|
306
|
+
coordinates,
|
|
307
|
+
animated,
|
|
308
|
+
duration,
|
|
309
|
+
easing,
|
|
310
|
+
trailLength,
|
|
311
|
+
delay,
|
|
312
|
+
hasGradient,
|
|
313
|
+
updatePath,
|
|
314
|
+
mapReady,
|
|
315
|
+
isDraggingRef,
|
|
316
|
+
]);
|
|
305
317
|
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
animated,
|
|
310
|
-
duration,
|
|
311
|
-
easing,
|
|
312
|
-
trailLength,
|
|
313
|
-
delay,
|
|
314
|
-
hasGradient,
|
|
315
|
-
updatePath,
|
|
316
|
-
mapReady,
|
|
317
|
-
]);
|
|
318
|
-
|
|
319
|
-
return null;
|
|
320
|
-
};
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
);
|