@lugg/maps 0.2.0-alpha.26 → 0.2.0-alpha.28
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/LuggMapView.kt +8 -2
- package/android/src/main/java/com/luggmaps/LuggMapViewManager.kt +17 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +29 -0
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +1 -0
- package/ios/LuggMapView.mm +12 -0
- package/ios/core/AppleMapProvider.mm +57 -0
- package/ios/core/GoogleMapProvider.mm +62 -6
- package/ios/core/MKPolylineAnimator.m +64 -27
- package/ios/core/MapProviderDelegate.h +3 -0
- package/ios/core/PolylineAnimatorBase.h +10 -1
- package/ios/core/PolylineAnimatorBase.m +49 -19
- package/lib/module/MapView.js +16 -2
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +42 -27
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Marker.js +12 -4
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Polyline.js +12 -4
- package/lib/module/components/Polyline.js.map +1 -1
- package/lib/module/components/index.js +2 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +2 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/src/MapView.d.ts +3 -2
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +8 -1
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.d.ts +4 -1
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.d.ts +4 -1
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- 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/fabric/LuggMapViewNativeComponent.d.ts +1 -0
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +4 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapView.tsx +13 -3
- package/src/MapView.types.ts +9 -1
- package/src/MapView.web.tsx +54 -37
- package/src/components/Marker.tsx +14 -2
- package/src/components/Polyline.tsx +14 -2
- package/src/components/index.ts +8 -2
- package/src/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/src/index.ts +9 -1
- package/src/index.web.ts +4 -1
package/src/MapView.web.tsx
CHANGED
|
@@ -25,9 +25,10 @@ import type {
|
|
|
25
25
|
MapViewRef,
|
|
26
26
|
MoveCameraOptions,
|
|
27
27
|
FitCoordinatesOptions,
|
|
28
|
+
SetEdgeInsetsOptions,
|
|
28
29
|
CameraEventPayload,
|
|
29
30
|
} from './MapView.types';
|
|
30
|
-
import type { Coordinate } from './types';
|
|
31
|
+
import type { Coordinate, EdgeInsets } from './types';
|
|
31
32
|
|
|
32
33
|
const createSyntheticEvent = <T,>(nativeEvent: T): NativeSyntheticEvent<T> =>
|
|
33
34
|
({
|
|
@@ -99,7 +100,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
99
100
|
ref
|
|
100
101
|
) {
|
|
101
102
|
const {
|
|
102
|
-
mapId =
|
|
103
|
+
mapId = 'DEMO_MAP_ID',
|
|
103
104
|
initialCoordinate,
|
|
104
105
|
initialZoom = 10,
|
|
105
106
|
minZoom,
|
|
@@ -126,15 +127,9 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
126
127
|
const prevEdgeInsets = useRef(edgeInsets);
|
|
127
128
|
|
|
128
129
|
const offsetCenter = useCallback(
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
edgeInsetsOverride?: typeof edgeInsets,
|
|
133
|
-
reverse = false
|
|
134
|
-
) => {
|
|
135
|
-
const p = edgeInsetsOverride ?? edgeInsets;
|
|
136
|
-
const div = map?.getDiv();
|
|
137
|
-
if (!p || !div) {
|
|
130
|
+
(coord: Coordinate, zoom: number, insets?: EdgeInsets, reverse = false) => {
|
|
131
|
+
const p = insets ?? prevEdgeInsets.current;
|
|
132
|
+
if (!p) {
|
|
138
133
|
return { lat: coord.latitude, lng: coord.longitude };
|
|
139
134
|
}
|
|
140
135
|
|
|
@@ -157,7 +152,41 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
157
152
|
|
|
158
153
|
return { lat, lng };
|
|
159
154
|
},
|
|
160
|
-
[
|
|
155
|
+
[]
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const applyEdgeInsets = useCallback(
|
|
159
|
+
(newEdgeInsets: EdgeInsets, duration?: number) => {
|
|
160
|
+
if (!map) return;
|
|
161
|
+
|
|
162
|
+
const prev = prevEdgeInsets.current;
|
|
163
|
+
const center = map.getCenter();
|
|
164
|
+
const zoom = map.getZoom() ?? initialZoom;
|
|
165
|
+
|
|
166
|
+
if (center) {
|
|
167
|
+
const logicalCenter = offsetCenter(
|
|
168
|
+
{ latitude: center.lat(), longitude: center.lng() },
|
|
169
|
+
zoom,
|
|
170
|
+
prev,
|
|
171
|
+
true
|
|
172
|
+
);
|
|
173
|
+
const newCenter = offsetCenter(
|
|
174
|
+
{ latitude: logicalCenter.lat, longitude: logicalCenter.lng },
|
|
175
|
+
zoom,
|
|
176
|
+
newEdgeInsets,
|
|
177
|
+
false
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (duration === 0) {
|
|
181
|
+
map.moveCamera({ center: newCenter, zoom });
|
|
182
|
+
} else {
|
|
183
|
+
map.panTo(newCenter);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
prevEdgeInsets.current = newEdgeInsets;
|
|
188
|
+
},
|
|
189
|
+
[map, initialZoom, offsetCenter]
|
|
161
190
|
);
|
|
162
191
|
|
|
163
192
|
useImperativeHandle(
|
|
@@ -190,7 +219,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
190
219
|
const first = coordinates[0];
|
|
191
220
|
if (!map || !first) return;
|
|
192
221
|
|
|
193
|
-
const {
|
|
222
|
+
const { padding: fitPadding, duration = -1 } = options ?? {};
|
|
194
223
|
|
|
195
224
|
if (coordinates.length === 1) {
|
|
196
225
|
this.moveCamera(first, { zoom: initialZoom, duration });
|
|
@@ -202,15 +231,20 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
202
231
|
bounds.extend({ lat: coord.latitude, lng: coord.longitude });
|
|
203
232
|
});
|
|
204
233
|
|
|
234
|
+
const ei = prevEdgeInsets.current;
|
|
205
235
|
map.fitBounds(bounds, {
|
|
206
|
-
top: (
|
|
207
|
-
left: (
|
|
208
|
-
bottom: (
|
|
209
|
-
right: (
|
|
236
|
+
top: (ei?.top ?? 0) + (fitPadding?.top ?? 0),
|
|
237
|
+
left: (ei?.left ?? 0) + (fitPadding?.left ?? 0),
|
|
238
|
+
bottom: (ei?.bottom ?? 0) + (fitPadding?.bottom ?? 0),
|
|
239
|
+
right: (ei?.right ?? 0) + (fitPadding?.right ?? 0),
|
|
210
240
|
});
|
|
211
241
|
},
|
|
242
|
+
|
|
243
|
+
setEdgeInsets(newEdgeInsets: EdgeInsets, options?: SetEdgeInsetsOptions) {
|
|
244
|
+
applyEdgeInsets(newEdgeInsets, options?.duration);
|
|
245
|
+
},
|
|
212
246
|
}),
|
|
213
|
-
[map, initialZoom,
|
|
247
|
+
[map, initialZoom, offsetCenter, applyEdgeInsets]
|
|
214
248
|
);
|
|
215
249
|
|
|
216
250
|
useEffect(() => {
|
|
@@ -231,26 +265,9 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
231
265
|
prev?.right !== edgeInsets.right;
|
|
232
266
|
|
|
233
267
|
if (changed) {
|
|
234
|
-
|
|
235
|
-
const zoom = map.getZoom() ?? initialZoom;
|
|
236
|
-
if (center) {
|
|
237
|
-
const logicalCenter = offsetCenter(
|
|
238
|
-
{ latitude: center.lat(), longitude: center.lng() },
|
|
239
|
-
zoom,
|
|
240
|
-
prev,
|
|
241
|
-
true
|
|
242
|
-
);
|
|
243
|
-
const newCenter = offsetCenter(
|
|
244
|
-
{ latitude: logicalCenter.lat, longitude: logicalCenter.lng },
|
|
245
|
-
zoom,
|
|
246
|
-
edgeInsets,
|
|
247
|
-
false
|
|
248
|
-
);
|
|
249
|
-
map.panTo(newCenter);
|
|
250
|
-
}
|
|
251
|
-
prevEdgeInsets.current = edgeInsets;
|
|
268
|
+
applyEdgeInsets(edgeInsets);
|
|
252
269
|
}
|
|
253
|
-
}, [map, edgeInsets,
|
|
270
|
+
}, [map, edgeInsets, applyEdgeInsets]);
|
|
254
271
|
|
|
255
272
|
const handleDragStart = () => {
|
|
256
273
|
setIsDragging(true);
|
|
@@ -52,7 +52,19 @@ export interface MarkerProps {
|
|
|
52
52
|
children?: ReactNode;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export class Marker extends React.
|
|
55
|
+
export class Marker extends React.PureComponent<MarkerProps> {
|
|
56
|
+
private getStyle(zIndex: number | undefined) {
|
|
57
|
+
if (zIndex == null) return styles.marker;
|
|
58
|
+
if (zIndex !== this._cachedZIndex) {
|
|
59
|
+
this._cachedZIndex = zIndex;
|
|
60
|
+
this._cachedStyle = [{ zIndex }, styles.marker];
|
|
61
|
+
}
|
|
62
|
+
return this._cachedStyle!;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private _cachedZIndex: number | undefined;
|
|
66
|
+
private _cachedStyle: any;
|
|
67
|
+
|
|
56
68
|
render() {
|
|
57
69
|
const {
|
|
58
70
|
name,
|
|
@@ -69,7 +81,7 @@ export class Marker extends React.Component<MarkerProps> {
|
|
|
69
81
|
|
|
70
82
|
return (
|
|
71
83
|
<LuggMarkerViewNativeComponent
|
|
72
|
-
style={
|
|
84
|
+
style={this.getStyle(zIndex)}
|
|
73
85
|
name={name}
|
|
74
86
|
coordinate={coordinate}
|
|
75
87
|
title={title}
|
|
@@ -57,7 +57,19 @@ export interface PolylineProps {
|
|
|
57
57
|
zIndex?: number;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export class Polyline extends React.
|
|
60
|
+
export class Polyline extends React.PureComponent<PolylineProps> {
|
|
61
|
+
private getStyle(zIndex: number | undefined) {
|
|
62
|
+
if (zIndex == null) return styles.polyline;
|
|
63
|
+
if (zIndex !== this._cachedZIndex) {
|
|
64
|
+
this._cachedZIndex = zIndex;
|
|
65
|
+
this._cachedStyle = [{ zIndex }, styles.polyline];
|
|
66
|
+
}
|
|
67
|
+
return this._cachedStyle!;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private _cachedZIndex: number | undefined;
|
|
71
|
+
private _cachedStyle: any;
|
|
72
|
+
|
|
61
73
|
render() {
|
|
62
74
|
const {
|
|
63
75
|
coordinates,
|
|
@@ -70,7 +82,7 @@ export class Polyline extends React.Component<PolylineProps> {
|
|
|
70
82
|
|
|
71
83
|
return (
|
|
72
84
|
<LuggPolylineViewNativeComponent
|
|
73
|
-
style={
|
|
85
|
+
style={this.getStyle(zIndex)}
|
|
74
86
|
coordinates={coordinates}
|
|
75
87
|
strokeColors={strokeColors}
|
|
76
88
|
strokeWidth={strokeWidth}
|
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';
|
|
@@ -77,10 +77,18 @@ interface NativeCommands {
|
|
|
77
77
|
edgeInsetsRight: Double,
|
|
78
78
|
duration: Double
|
|
79
79
|
) => void;
|
|
80
|
+
setEdgeInsets: (
|
|
81
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
82
|
+
top: Double,
|
|
83
|
+
left: Double,
|
|
84
|
+
bottom: Double,
|
|
85
|
+
right: Double,
|
|
86
|
+
duration: Double
|
|
87
|
+
) => void;
|
|
80
88
|
}
|
|
81
89
|
|
|
82
90
|
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
83
|
-
supportedCommands: ['moveCamera', 'fitCoordinates'],
|
|
91
|
+
supportedCommands: ['moveCamera', 'fitCoordinates', 'setEdgeInsets'],
|
|
84
92
|
});
|
|
85
93
|
|
|
86
94
|
export default codegenNativeComponent<NativeProps>(
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
export { MapView } from './MapView';
|
|
2
2
|
export { MapProvider } from './MapProvider';
|
|
3
3
|
export type { MapProviderProps } from './MapProvider.types';
|
|
4
|
-
export
|
|
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';
|
|
5
12
|
export type {
|
|
6
13
|
MapViewProps,
|
|
7
14
|
MapViewRef,
|
|
8
15
|
MoveCameraOptions,
|
|
9
16
|
FitCoordinatesOptions,
|
|
17
|
+
SetEdgeInsetsOptions,
|
|
10
18
|
CameraEventPayload,
|
|
11
19
|
} from './MapView.types';
|
|
12
20
|
export type {
|
package/src/index.web.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export { MapView } from './MapView.web';
|
|
2
2
|
export { MapProvider } from './MapProvider.web';
|
|
3
3
|
export type { MapProviderProps } from './MapProvider.types';
|
|
4
|
-
export
|
|
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';
|
|
5
8
|
export type {
|
|
6
9
|
MapViewProps,
|
|
7
10
|
MapViewRef,
|