@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,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
|
+
);
|
package/src/components/index.ts
CHANGED
|
@@ -62,6 +62,10 @@ export interface ReadyEvent {}
|
|
|
62
62
|
|
|
63
63
|
export interface NativeProps extends ViewProps {
|
|
64
64
|
provider?: WithDefault<'google' | 'apple', 'google'>;
|
|
65
|
+
mapType?: WithDefault<
|
|
66
|
+
'standard' | 'satellite' | 'terrain' | 'hybrid' | 'muted-standard',
|
|
67
|
+
'standard'
|
|
68
|
+
>;
|
|
65
69
|
mapId?: string;
|
|
66
70
|
initialCoordinate?: Coordinate;
|
|
67
71
|
initialZoom?: Double;
|
|
@@ -74,7 +78,11 @@ export interface NativeProps extends ViewProps {
|
|
|
74
78
|
edgeInsets?: EdgeInsets;
|
|
75
79
|
userLocationEnabled?: boolean;
|
|
76
80
|
userLocationButtonEnabled?: boolean;
|
|
77
|
-
|
|
81
|
+
poiEnabled?: boolean;
|
|
82
|
+
poiFilterMode?: WithDefault<'including' | 'excluding', 'including'>;
|
|
83
|
+
poiFilterCategories?: ReadonlyArray<string>;
|
|
84
|
+
theme?: WithDefault<'system' | 'light' | 'dark', 'system'>;
|
|
85
|
+
insetAdjustment?: WithDefault<'never' | 'automatic', 'never'>;
|
|
78
86
|
onMapPress?: DirectEventHandler<PressEvent>;
|
|
79
87
|
onMapLongPress?: DirectEventHandler<LongPressEvent>;
|
|
80
88
|
onCameraMove?: DirectEventHandler<CameraMoveEvent>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { codegenNativeComponent } from 'react-native';
|
|
1
|
+
import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
|
|
2
2
|
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
3
|
import type {
|
|
4
4
|
Double,
|
|
@@ -25,6 +25,7 @@ export interface NativeProps extends ViewProps {
|
|
|
25
25
|
rotate?: WithDefault<Double, 0>;
|
|
26
26
|
scale?: WithDefault<Double, 1>;
|
|
27
27
|
rasterize?: WithDefault<boolean, true>;
|
|
28
|
+
centerOnPress?: WithDefault<boolean, true>;
|
|
28
29
|
draggable?: WithDefault<boolean, false>;
|
|
29
30
|
onMarkerPress?: DirectEventHandler<{
|
|
30
31
|
coordinate: {
|
|
@@ -68,6 +69,17 @@ export interface NativeProps extends ViewProps {
|
|
|
68
69
|
}>;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
73
|
+
|
|
74
|
+
interface NativeCommands {
|
|
75
|
+
showCallout: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
76
|
+
hideCallout: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
80
|
+
supportedCommands: ['showCallout', 'hideCallout'],
|
|
81
|
+
});
|
|
82
|
+
|
|
71
83
|
export default codegenNativeComponent<NativeProps>(
|
|
72
84
|
'LuggMarkerView'
|
|
73
|
-
) as
|
|
85
|
+
) as ComponentType;
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { MapProviderProps } from './MapProvider.types';
|
|
|
4
4
|
export { Marker } from './components';
|
|
5
5
|
export type {
|
|
6
6
|
CalloutOptions,
|
|
7
|
+
MarkerRef,
|
|
7
8
|
MarkerProps,
|
|
8
9
|
MarkerPressEvent,
|
|
9
10
|
MarkerDragEvent,
|
|
@@ -33,10 +34,14 @@ export type {
|
|
|
33
34
|
CameraEventPayload,
|
|
34
35
|
MapCameraEvent,
|
|
35
36
|
MapPressEvent,
|
|
37
|
+
MapType,
|
|
38
|
+
MapTheme,
|
|
39
|
+
InsetAdjustment,
|
|
40
|
+
PoiCategory,
|
|
41
|
+
PoiFilter,
|
|
36
42
|
} from './MapView.types';
|
|
37
43
|
export type {
|
|
38
44
|
MapProvider as MapProviderType,
|
|
39
|
-
MapTheme,
|
|
40
45
|
Coordinate,
|
|
41
46
|
Point,
|
|
42
47
|
EdgeInsets,
|
package/src/index.web.ts
CHANGED