@lugg/maps 1.0.0-beta.5 → 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/ios/core/AppleMapProvider.mm +81 -42
- package/lib/module/MapProvider.web.js +4 -1
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +1 -1
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +18 -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.web.js +6 -6
- 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/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 +1 -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.web.d.ts +1 -1
- 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/package.json +1 -1
- package/src/MapProvider.web.tsx +5 -3
- package/src/MapView.tsx +1 -1
- package/src/MapView.types.ts +33 -0
- package/src/MapView.web.tsx +378 -356
- 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.web.tsx +184 -181
- package/src/components/Polygon.web.tsx +93 -89
- package/src/components/Polyline.web.tsx +235 -235
- package/src/components/TileOverlay.web.tsx +83 -81
|
@@ -1,95 +1,97 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
1
|
+
import { memo, useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { useMapContext } from '../MapProvider.web';
|
|
3
3
|
import type { TileOverlayProps } from './TileOverlay.types';
|
|
4
4
|
|
|
5
|
-
export const TileOverlay = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
export const TileOverlay = memo(
|
|
6
|
+
({
|
|
7
|
+
urlTemplate,
|
|
8
|
+
tileSize = 256,
|
|
9
|
+
opacity = 1,
|
|
10
|
+
bounds,
|
|
11
|
+
zIndex = 0,
|
|
12
|
+
onPress,
|
|
13
|
+
}: TileOverlayProps) => {
|
|
14
|
+
const { map } = useMapContext();
|
|
15
|
+
const overlayRef = useRef<google.maps.ImageMapType | null>(null);
|
|
16
|
+
const indexRef = useRef<number>(-1);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const handleClick = useCallback(() => {
|
|
19
|
+
onPress?.();
|
|
20
|
+
}, [onPress]);
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
// Cleanup on unmount
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
return () => {
|
|
25
|
+
if (overlayRef.current && indexRef.current >= 0) {
|
|
26
|
+
map?.overlayMapTypes.removeAt(indexRef.current);
|
|
27
|
+
}
|
|
28
|
+
overlayRef.current = null;
|
|
29
|
+
indexRef.current = -1;
|
|
30
|
+
};
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, []);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// Sync overlay with props
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!map) return;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
// Remove old overlay
|
|
39
|
+
if (overlayRef.current && indexRef.current >= 0) {
|
|
40
|
+
map.overlayMapTypes.removeAt(indexRef.current);
|
|
41
|
+
overlayRef.current = null;
|
|
42
|
+
indexRef.current = -1;
|
|
43
|
+
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
if (!urlTemplate) return;
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
const imageMapType = new google.maps.ImageMapType({
|
|
48
|
+
getTileUrl: (coord, zoom) => {
|
|
49
|
+
if (bounds) {
|
|
50
|
+
const n = Math.pow(2, zoom);
|
|
51
|
+
const tileSWLat =
|
|
52
|
+
(Math.atan(Math.sinh(Math.PI * (1 - (2 * (coord.y + 1)) / n))) *
|
|
53
|
+
180) /
|
|
54
|
+
Math.PI;
|
|
55
|
+
const tileNELat =
|
|
56
|
+
(Math.atan(Math.sinh(Math.PI * (1 - (2 * coord.y) / n))) * 180) /
|
|
57
|
+
Math.PI;
|
|
58
|
+
const tileSWLng = (coord.x / n) * 360 - 180;
|
|
59
|
+
const tileNELng = ((coord.x + 1) / n) * 360 - 180;
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
if (
|
|
62
|
+
tileNELat < bounds.southwest.latitude ||
|
|
63
|
+
tileSWLat > bounds.northeast.latitude ||
|
|
64
|
+
tileNELng < bounds.southwest.longitude ||
|
|
65
|
+
tileSWLng > bounds.northeast.longitude
|
|
66
|
+
) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
67
69
|
}
|
|
68
|
-
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
return urlTemplate
|
|
72
|
+
.replace('{x}', String(coord.x))
|
|
73
|
+
.replace('{y}', String(coord.y))
|
|
74
|
+
.replace('{z}', String(zoom));
|
|
75
|
+
},
|
|
76
|
+
tileSize: new google.maps.Size(tileSize, tileSize),
|
|
77
|
+
opacity,
|
|
78
|
+
});
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
const length = map.overlayMapTypes.getLength();
|
|
81
|
+
map.overlayMapTypes.insertAt(length, imageMapType);
|
|
82
|
+
overlayRef.current = imageMapType;
|
|
83
|
+
indexRef.current = length;
|
|
84
|
+
}, [
|
|
85
|
+
map,
|
|
86
|
+
urlTemplate,
|
|
87
|
+
tileSize,
|
|
88
|
+
opacity,
|
|
89
|
+
bounds,
|
|
90
|
+
zIndex,
|
|
91
|
+
onPress,
|
|
92
|
+
handleClick,
|
|
93
|
+
]);
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
);
|