@lugg/maps 0.2.0-alpha.3 → 0.2.0-alpha.30
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/README.md +21 -3
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +265 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +75 -36
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +6 -5
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +136 -14
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +21 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +1 -4
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +16 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +22 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapView.kt → core/GoogleMapProvider.kt} +251 -241
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +55 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +163 -52
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +312 -0
- package/ios/LuggMarkerView.h +9 -0
- package/ios/LuggMarkerView.mm +79 -0
- package/ios/LuggPolylineView.h +4 -0
- package/ios/LuggPolylineView.mm +23 -0
- package/ios/core/AppleMapProvider.h +15 -0
- package/ios/core/AppleMapProvider.mm +664 -0
- package/ios/core/GMSPolylineAnimator.h +3 -0
- package/ios/core/GMSPolylineAnimator.m +175 -40
- package/ios/core/GoogleMapProvider.h +13 -0
- package/ios/core/GoogleMapProvider.mm +513 -0
- package/ios/core/MKPolylineAnimator.h +4 -0
- package/ios/core/MKPolylineAnimator.m +224 -68
- package/ios/core/MapProviderDelegate.h +72 -0
- package/ios/core/PolylineAnimatorBase.h +24 -1
- package/ios/core/PolylineAnimatorBase.m +82 -19
- package/ios/extensions/MKMapView+Zoom.h +2 -0
- package/ios/extensions/MKMapView+Zoom.m +14 -4
- package/lib/module/MapProvider.js +13 -0
- package/lib/module/MapProvider.js.map +1 -0
- package/lib/module/MapProvider.types.js +4 -0
- package/lib/module/MapProvider.types.js.map +1 -0
- package/lib/module/MapProvider.web.js +20 -0
- package/lib/module/MapProvider.web.js.map +1 -0
- package/lib/module/MapView.js +29 -16
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +290 -0
- package/lib/module/MapView.web.js.map +1 -0
- package/lib/module/components/Marker.js +19 -2
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +33 -0
- package/lib/module/components/Marker.web.js.map +1 -0
- package/lib/module/components/Polyline.js +17 -4
- package/lib/module/components/Polyline.js.map +1 -1
- package/lib/module/components/Polyline.web.js +229 -0
- package/lib/module/components/Polyline.web.js.map +1 -0
- package/lib/module/components/index.js +2 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +5 -0
- package/lib/module/components/index.web.js.map +1 -0
- package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +19 -7
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +7 -1
- package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/lib/module/index.js +4 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +7 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/typescript/src/MapProvider.d.ts +8 -0
- package/lib/typescript/src/MapProvider.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.types.d.ts +16 -0
- package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.web.d.ts +11 -0
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -0
- package/lib/typescript/src/MapView.d.ts +4 -4
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +23 -7
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +3 -0
- package/lib/typescript/src/MapView.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +25 -1
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +3 -0
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +36 -1
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts +3 -0
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +4 -2
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +5 -0
- package/lib/typescript/src/components/index.web.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +8 -4
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +4 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts +7 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +8 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +10 -0
- package/lib/typescript/src/index.web.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +4 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +17 -3
- package/src/MapProvider.tsx +10 -0
- package/src/MapProvider.types.ts +16 -0
- package/src/MapProvider.web.tsx +14 -0
- package/src/MapView.tsx +28 -26
- package/src/MapView.types.ts +24 -7
- package/src/MapView.web.tsx +364 -0
- package/src/components/Marker.tsx +50 -4
- package/src/components/Marker.web.tsx +33 -0
- package/src/components/Polyline.tsx +51 -2
- package/src/components/Polyline.web.tsx +287 -0
- package/src/components/index.ts +8 -2
- package/src/components/index.web.ts +4 -0
- package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +19 -7
- package/src/fabric/LuggMarkerViewNativeComponent.ts +7 -1
- package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/src/index.ts +18 -2
- package/src/index.web.ts +20 -0
- package/src/types.ts +5 -0
- package/ios/LuggAppleMapView.h +0 -16
- package/ios/LuggAppleMapView.mm +0 -580
- package/ios/LuggGoogleMapView.h +0 -13
- package/ios/LuggGoogleMapView.mm +0 -454
- package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -54
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useMapContext } from '../MapProvider.web';
|
|
3
|
+
import type { PolylineProps, PolylineEasing } from './Polyline';
|
|
4
|
+
|
|
5
|
+
const DEFAULT_DURATION = 2150;
|
|
6
|
+
|
|
7
|
+
function applyEasing(t: number, easing: PolylineEasing = 'linear'): number {
|
|
8
|
+
switch (easing) {
|
|
9
|
+
case 'easeIn':
|
|
10
|
+
return t * t;
|
|
11
|
+
case 'easeOut':
|
|
12
|
+
return t * (2 - t);
|
|
13
|
+
case 'easeInOut':
|
|
14
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
15
|
+
default:
|
|
16
|
+
return t;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function interpolateColor(color1: string, color2: string, t: number): string {
|
|
21
|
+
const hex = (c: string) => parseInt(c, 16);
|
|
22
|
+
const r1 = hex(color1.slice(1, 3));
|
|
23
|
+
const g1 = hex(color1.slice(3, 5));
|
|
24
|
+
const b1 = hex(color1.slice(5, 7));
|
|
25
|
+
const r2 = hex(color2.slice(1, 3));
|
|
26
|
+
const g2 = hex(color2.slice(3, 5));
|
|
27
|
+
const b2 = hex(color2.slice(5, 7));
|
|
28
|
+
|
|
29
|
+
const r = Math.round(r1 + (r2 - r1) * t);
|
|
30
|
+
const g = Math.round(g1 + (g2 - g1) * t);
|
|
31
|
+
const b = Math.round(b1 + (b2 - b1) * t);
|
|
32
|
+
|
|
33
|
+
return `#${r.toString(16).padStart(2, '0')}${g
|
|
34
|
+
.toString(16)
|
|
35
|
+
.padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getGradientColor(colors: string[], position: number): string {
|
|
39
|
+
if (colors.length === 0) return '#000000';
|
|
40
|
+
if (colors.length === 1 || position <= 0) return colors[0]!;
|
|
41
|
+
if (position >= 1) return colors[colors.length - 1]!;
|
|
42
|
+
|
|
43
|
+
const scaledPos = position * (colors.length - 1);
|
|
44
|
+
const index = Math.floor(scaledPos);
|
|
45
|
+
const t = scaledPos - index;
|
|
46
|
+
|
|
47
|
+
return interpolateColor(colors[index]!, colors[index + 1]!, t);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function Polyline({
|
|
51
|
+
coordinates,
|
|
52
|
+
strokeColors,
|
|
53
|
+
strokeWidth = 1,
|
|
54
|
+
animated,
|
|
55
|
+
animatedOptions,
|
|
56
|
+
zIndex,
|
|
57
|
+
}: PolylineProps) {
|
|
58
|
+
const resolvedZIndex = zIndex ?? (animated ? 1 : 0);
|
|
59
|
+
const { map, isDragging } = useMapContext();
|
|
60
|
+
const polylinesRef = useRef<google.maps.Polyline[]>([]);
|
|
61
|
+
const animationRef = useRef<number>(0);
|
|
62
|
+
const isPausedRef = useRef(false);
|
|
63
|
+
|
|
64
|
+
const colors = useMemo(
|
|
65
|
+
() =>
|
|
66
|
+
strokeColors && strokeColors.length > 0
|
|
67
|
+
? (strokeColors as string[])
|
|
68
|
+
: ['#000000'],
|
|
69
|
+
[strokeColors]
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const hasGradient = colors.length > 1;
|
|
73
|
+
|
|
74
|
+
// Refs for animation loop access
|
|
75
|
+
const propsRef = useRef({
|
|
76
|
+
map,
|
|
77
|
+
colors,
|
|
78
|
+
strokeWidth,
|
|
79
|
+
hasGradient,
|
|
80
|
+
zIndex: resolvedZIndex,
|
|
81
|
+
});
|
|
82
|
+
const [mapReady, setMapReady] = useState(!!map);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
propsRef.current = {
|
|
86
|
+
map,
|
|
87
|
+
colors,
|
|
88
|
+
strokeWidth,
|
|
89
|
+
hasGradient,
|
|
90
|
+
zIndex: resolvedZIndex,
|
|
91
|
+
};
|
|
92
|
+
if (map && !mapReady) setMapReady(true);
|
|
93
|
+
}, [map, colors, strokeWidth, hasGradient, resolvedZIndex, mapReady]);
|
|
94
|
+
|
|
95
|
+
const updatePath = useCallback((path: google.maps.LatLngLiteral[]) => {
|
|
96
|
+
const {
|
|
97
|
+
map: currentMap,
|
|
98
|
+
colors: currentColors,
|
|
99
|
+
strokeWidth: currentStrokeWidth,
|
|
100
|
+
hasGradient: currentHasGradient,
|
|
101
|
+
zIndex: currentZIndex,
|
|
102
|
+
} = propsRef.current;
|
|
103
|
+
if (!currentMap || path.length < 2) return;
|
|
104
|
+
|
|
105
|
+
const neededSegments = currentHasGradient ? path.length - 1 : 1;
|
|
106
|
+
const existing = polylinesRef.current;
|
|
107
|
+
|
|
108
|
+
// Update or create segments
|
|
109
|
+
for (let i = 0; i < neededSegments; i++) {
|
|
110
|
+
const segmentPath = currentHasGradient ? [path[i]!, path[i + 1]!] : path;
|
|
111
|
+
const color = currentHasGradient
|
|
112
|
+
? getGradientColor(currentColors, i / (path.length - 1))
|
|
113
|
+
: currentColors[0]!;
|
|
114
|
+
|
|
115
|
+
const segment = existing[i];
|
|
116
|
+
if (segment) {
|
|
117
|
+
segment.setPath(segmentPath);
|
|
118
|
+
segment.setOptions({ strokeColor: color });
|
|
119
|
+
} else {
|
|
120
|
+
existing.push(
|
|
121
|
+
new google.maps.Polyline({
|
|
122
|
+
path: segmentPath,
|
|
123
|
+
strokeColor: color,
|
|
124
|
+
strokeWeight: currentStrokeWidth,
|
|
125
|
+
strokeOpacity: 1,
|
|
126
|
+
zIndex: currentZIndex,
|
|
127
|
+
map: currentMap,
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Remove extra segments
|
|
134
|
+
for (let i = neededSegments; i < existing.length; i++) {
|
|
135
|
+
existing[i]?.setMap(null);
|
|
136
|
+
}
|
|
137
|
+
existing.length = neededSegments;
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
// Cleanup on unmount
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
const polylines = polylinesRef.current;
|
|
143
|
+
return () => {
|
|
144
|
+
cancelAnimationFrame(animationRef.current);
|
|
145
|
+
polylines.forEach((p) => p.setMap(null));
|
|
146
|
+
};
|
|
147
|
+
}, []);
|
|
148
|
+
|
|
149
|
+
// Pause/resume animation during drag
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
isPausedRef.current = isDragging;
|
|
152
|
+
}, [isDragging]);
|
|
153
|
+
|
|
154
|
+
// Main effect
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (!propsRef.current.map || coordinates.length === 0) return;
|
|
157
|
+
|
|
158
|
+
const fullPath = coordinates.map((c) => ({
|
|
159
|
+
lat: c.latitude,
|
|
160
|
+
lng: c.longitude,
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
cancelAnimationFrame(animationRef.current);
|
|
164
|
+
|
|
165
|
+
if (!animated) {
|
|
166
|
+
updatePath(fullPath);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const duration = animatedOptions?.duration ?? DEFAULT_DURATION;
|
|
171
|
+
const easing = animatedOptions?.easing ?? 'linear';
|
|
172
|
+
const trailLength = Math.max(
|
|
173
|
+
0.01,
|
|
174
|
+
Math.min(1, animatedOptions?.trailLength ?? 1)
|
|
175
|
+
);
|
|
176
|
+
const delay = animatedOptions?.delay ?? 0;
|
|
177
|
+
|
|
178
|
+
const totalPoints = fullPath.length;
|
|
179
|
+
const useTrailMode = trailLength < 1;
|
|
180
|
+
const cycleDuration = useTrailMode ? duration : duration * 2;
|
|
181
|
+
|
|
182
|
+
let startTime: number | null = null;
|
|
183
|
+
let delayRemaining = delay;
|
|
184
|
+
|
|
185
|
+
const animate = (time: number) => {
|
|
186
|
+
if (isPausedRef.current) {
|
|
187
|
+
startTime = null;
|
|
188
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (startTime === null) {
|
|
193
|
+
startTime = time;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const elapsed = time - startTime;
|
|
197
|
+
|
|
198
|
+
if (delayRemaining > 0) {
|
|
199
|
+
if (elapsed < delayRemaining) {
|
|
200
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
startTime = time - (elapsed - delayRemaining);
|
|
204
|
+
delayRemaining = 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const rawProgress = ((time - startTime) % cycleDuration) / duration;
|
|
208
|
+
const maxProgress = useTrailMode ? 1 : 2;
|
|
209
|
+
const clampedProgress = Math.min(rawProgress, maxProgress);
|
|
210
|
+
const easedProgress =
|
|
211
|
+
applyEasing(clampedProgress / maxProgress, easing) * maxProgress;
|
|
212
|
+
|
|
213
|
+
let startIdx: number;
|
|
214
|
+
let endIdx: number;
|
|
215
|
+
|
|
216
|
+
if (useTrailMode) {
|
|
217
|
+
endIdx = easedProgress * totalPoints;
|
|
218
|
+
startIdx = Math.max(0, endIdx - trailLength * totalPoints);
|
|
219
|
+
} else {
|
|
220
|
+
startIdx = easedProgress <= 1 ? 0 : (easedProgress - 1) * totalPoints;
|
|
221
|
+
endIdx = easedProgress <= 1 ? easedProgress * totalPoints : totalPoints;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (rawProgress >= maxProgress) {
|
|
225
|
+
delayRemaining = delay;
|
|
226
|
+
startTime = time;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const partialPath: google.maps.LatLngLiteral[] = [];
|
|
230
|
+
const startFloor = Math.floor(startIdx);
|
|
231
|
+
const endFloor = Math.floor(endIdx);
|
|
232
|
+
|
|
233
|
+
// Start point (interpolated)
|
|
234
|
+
if (startFloor < totalPoints) {
|
|
235
|
+
const frac = startIdx - startFloor;
|
|
236
|
+
const from = fullPath[startFloor]!;
|
|
237
|
+
const to = fullPath[Math.min(startFloor + 1, totalPoints - 1)]!;
|
|
238
|
+
partialPath.push(
|
|
239
|
+
frac > 0
|
|
240
|
+
? {
|
|
241
|
+
lat: from.lat + (to.lat - from.lat) * frac,
|
|
242
|
+
lng: from.lng + (to.lng - from.lng) * frac,
|
|
243
|
+
}
|
|
244
|
+
: from
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Middle points
|
|
249
|
+
for (
|
|
250
|
+
let i = startFloor + 1;
|
|
251
|
+
i <= Math.min(endFloor, totalPoints - 1);
|
|
252
|
+
i++
|
|
253
|
+
) {
|
|
254
|
+
partialPath.push(fullPath[i]!);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// End point (interpolated)
|
|
258
|
+
if (endFloor < totalPoints - 1) {
|
|
259
|
+
const frac = endIdx - endFloor;
|
|
260
|
+
const from = fullPath[endFloor]!;
|
|
261
|
+
const to = fullPath[endFloor + 1]!;
|
|
262
|
+
if (frac > 0) {
|
|
263
|
+
partialPath.push({
|
|
264
|
+
lat: from.lat + (to.lat - from.lat) * frac,
|
|
265
|
+
lng: from.lng + (to.lng - from.lng) * frac,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
updatePath(partialPath);
|
|
271
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
275
|
+
|
|
276
|
+
return () => cancelAnimationFrame(animationRef.current);
|
|
277
|
+
}, [
|
|
278
|
+
coordinates,
|
|
279
|
+
animated,
|
|
280
|
+
animatedOptions,
|
|
281
|
+
hasGradient,
|
|
282
|
+
updatePath,
|
|
283
|
+
mapReady,
|
|
284
|
+
]);
|
|
285
|
+
|
|
286
|
+
return null;
|
|
287
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { Marker } from './Marker';
|
|
2
|
+
export type { MarkerProps } from './Marker';
|
|
3
|
+
export { Polyline } from './Polyline';
|
|
4
|
+
export type {
|
|
5
|
+
PolylineProps,
|
|
6
|
+
PolylineEasing,
|
|
7
|
+
PolylineAnimatedOptions,
|
|
8
|
+
} from './Polyline';
|
|
@@ -2,6 +2,7 @@ import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
|
|
|
2
2
|
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
3
|
import type {
|
|
4
4
|
Double,
|
|
5
|
+
WithDefault,
|
|
5
6
|
DirectEventHandler,
|
|
6
7
|
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
8
|
|
|
@@ -38,6 +39,7 @@ export interface CameraIdleEvent {
|
|
|
38
39
|
export interface ReadyEvent {}
|
|
39
40
|
|
|
40
41
|
export interface NativeProps extends ViewProps {
|
|
42
|
+
provider?: WithDefault<'google' | 'apple', 'google'>;
|
|
41
43
|
mapId?: string;
|
|
42
44
|
initialCoordinate?: Coordinate;
|
|
43
45
|
initialZoom?: Double;
|
|
@@ -47,8 +49,10 @@ export interface NativeProps extends ViewProps {
|
|
|
47
49
|
scrollEnabled?: boolean;
|
|
48
50
|
rotateEnabled?: boolean;
|
|
49
51
|
pitchEnabled?: boolean;
|
|
50
|
-
|
|
52
|
+
edgeInsets?: EdgeInsets;
|
|
51
53
|
userLocationEnabled?: boolean;
|
|
54
|
+
userLocationButtonEnabled?: boolean;
|
|
55
|
+
theme?: WithDefault<'light' | 'dark' | 'system', 'system'>;
|
|
52
56
|
onCameraMove?: DirectEventHandler<CameraMoveEvent>;
|
|
53
57
|
onCameraIdle?: DirectEventHandler<CameraIdleEvent>;
|
|
54
58
|
onReady?: DirectEventHandler<ReadyEvent>;
|
|
@@ -67,18 +71,26 @@ interface NativeCommands {
|
|
|
67
71
|
fitCoordinates: (
|
|
68
72
|
viewRef: React.ElementRef<ComponentType>,
|
|
69
73
|
coordinates: Coordinate[],
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
edgeInsetsTop: Double,
|
|
75
|
+
edgeInsetsLeft: Double,
|
|
76
|
+
edgeInsetsBottom: Double,
|
|
77
|
+
edgeInsetsRight: Double,
|
|
78
|
+
duration: Double
|
|
79
|
+
) => void;
|
|
80
|
+
setEdgeInsets: (
|
|
81
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
82
|
+
top: Double,
|
|
83
|
+
left: Double,
|
|
84
|
+
bottom: Double,
|
|
85
|
+
right: Double,
|
|
74
86
|
duration: Double
|
|
75
87
|
) => void;
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
79
|
-
supportedCommands: ['moveCamera', 'fitCoordinates'],
|
|
91
|
+
supportedCommands: ['moveCamera', 'fitCoordinates', 'setEdgeInsets'],
|
|
80
92
|
});
|
|
81
93
|
|
|
82
94
|
export default codegenNativeComponent<NativeProps>(
|
|
83
|
-
'
|
|
95
|
+
'LuggMapView'
|
|
84
96
|
) as ComponentType;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { codegenNativeComponent } from 'react-native';
|
|
2
2
|
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
WithDefault,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
7
|
|
|
5
8
|
export interface Coordinate {
|
|
6
9
|
latitude: Double;
|
|
@@ -18,6 +21,9 @@ export interface NativeProps extends ViewProps {
|
|
|
18
21
|
title?: string;
|
|
19
22
|
description?: string;
|
|
20
23
|
anchor?: Point;
|
|
24
|
+
rotate?: WithDefault<Double, 0>;
|
|
25
|
+
scale?: WithDefault<Double, 1>;
|
|
26
|
+
rasterize?: WithDefault<boolean, true>;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export default codegenNativeComponent<NativeProps>(
|
|
@@ -7,11 +7,19 @@ export interface Coordinate {
|
|
|
7
7
|
longitude: Double;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface AnimatedOptions {
|
|
11
|
+
duration?: Double;
|
|
12
|
+
easing?: string;
|
|
13
|
+
trailLength?: Double;
|
|
14
|
+
delay?: Double;
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
export interface NativeProps extends ViewProps {
|
|
11
18
|
coordinates: ReadonlyArray<Coordinate>;
|
|
12
19
|
strokeColors?: ReadonlyArray<ColorValue>;
|
|
13
20
|
strokeWidth?: Double;
|
|
14
21
|
animated?: boolean;
|
|
22
|
+
animatedOptions?: AnimatedOptions;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
export default codegenNativeComponent<NativeProps>(
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
export { MapView } from './MapView';
|
|
2
|
-
export
|
|
2
|
+
export { MapProvider } from './MapProvider';
|
|
3
|
+
export type { MapProviderProps } from './MapProvider.types';
|
|
4
|
+
export { Marker } from './components';
|
|
5
|
+
export type { MarkerProps } from './components';
|
|
6
|
+
export { Polyline } from './components';
|
|
7
|
+
export type {
|
|
8
|
+
PolylineProps,
|
|
9
|
+
PolylineEasing,
|
|
10
|
+
PolylineAnimatedOptions,
|
|
11
|
+
} from './components';
|
|
3
12
|
export type {
|
|
4
13
|
MapViewProps,
|
|
5
14
|
MapViewRef,
|
|
6
15
|
MoveCameraOptions,
|
|
7
16
|
FitCoordinatesOptions,
|
|
17
|
+
SetEdgeInsetsOptions,
|
|
8
18
|
CameraEventPayload,
|
|
9
19
|
} from './MapView.types';
|
|
10
|
-
export type {
|
|
20
|
+
export type {
|
|
21
|
+
MapProvider as MapProviderType,
|
|
22
|
+
MapTheme,
|
|
23
|
+
Coordinate,
|
|
24
|
+
Point,
|
|
25
|
+
EdgeInsets,
|
|
26
|
+
} from './types';
|
package/src/index.web.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { MapView } from './MapView.web';
|
|
2
|
+
export { MapProvider } from './MapProvider.web';
|
|
3
|
+
export type { MapProviderProps } from './MapProvider.types';
|
|
4
|
+
export { Marker } from './components/index.web';
|
|
5
|
+
export type { MarkerProps } from './components/index.web';
|
|
6
|
+
export { Polyline } from './components/index.web';
|
|
7
|
+
export type { PolylineProps } from './components/index.web';
|
|
8
|
+
export type {
|
|
9
|
+
MapViewProps,
|
|
10
|
+
MapViewRef,
|
|
11
|
+
MoveCameraOptions,
|
|
12
|
+
FitCoordinatesOptions,
|
|
13
|
+
CameraEventPayload,
|
|
14
|
+
} from './MapView.types';
|
|
15
|
+
export type {
|
|
16
|
+
MapProvider as MapProviderType,
|
|
17
|
+
Coordinate,
|
|
18
|
+
Point,
|
|
19
|
+
EdgeInsets,
|
|
20
|
+
} from './types';
|
package/src/types.ts
CHANGED
package/ios/LuggAppleMapView.h
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#import <MapKit/MapKit.h>
|
|
2
|
-
#import <React/RCTViewComponentView.h>
|
|
3
|
-
#import <UIKit/UIKit.h>
|
|
4
|
-
|
|
5
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
-
|
|
7
|
-
@interface LuggAppleMapViewContent : MKMapView
|
|
8
|
-
@end
|
|
9
|
-
|
|
10
|
-
@interface LuggAppleMapView : RCTViewComponentView
|
|
11
|
-
|
|
12
|
-
- (MKMapView *)mapView;
|
|
13
|
-
|
|
14
|
-
@end
|
|
15
|
-
|
|
16
|
-
NS_ASSUME_NONNULL_END
|