@lugg/maps 1.0.0-beta.3 → 1.0.0-beta.5
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 +3 -0
- 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/LuggCircleView.kt +85 -0
- package/android/src/main/java/com/luggmaps/LuggCircleViewManager.kt +79 -0
- package/android/src/main/java/com/luggmaps/LuggGroundOverlayView.kt +81 -0
- package/android/src/main/java/com/luggmaps/LuggGroundOverlayViewManager.kt +82 -0
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +49 -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/LuggPackage.kt +4 -1
- package/android/src/main/java/com/luggmaps/LuggTileOverlayView.kt +92 -0
- package/android/src/main/java/com/luggmaps/LuggTileOverlayViewManager.kt +80 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +451 -17
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +14 -0
- package/android/src/main/java/com/luggmaps/events/CirclePressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/GroundOverlayPressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/TileOverlayPressEvent.kt +12 -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/LuggCircleView.h +31 -0
- package/ios/LuggCircleView.mm +133 -0
- package/ios/LuggGroundOverlayView.h +30 -0
- package/ios/LuggGroundOverlayView.mm +125 -0
- package/ios/LuggMapView.mm +84 -2
- package/ios/LuggMarkerView.h +3 -0
- package/ios/LuggMarkerView.mm +23 -0
- package/ios/LuggTileOverlayView.h +31 -0
- package/ios/LuggTileOverlayView.mm +130 -0
- package/ios/core/AppleMapProvider.mm +595 -17
- package/ios/core/GoogleMapProvider.mm +390 -28
- package/ios/core/MapProviderDelegate.h +20 -1
- package/ios/events/CirclePressEvent.h +20 -0
- package/ios/events/GroundOverlayPressEvent.h +20 -0
- package/ios/events/TileOverlayPressEvent.h +20 -0
- package/lib/module/MapView.js +11 -0
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +3 -0
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Circle.js +46 -0
- package/lib/module/components/Circle.js.map +1 -0
- package/lib/module/components/Circle.types.js +4 -0
- package/lib/module/components/Circle.types.js.map +1 -0
- package/lib/module/components/Circle.web.js +79 -0
- package/lib/module/components/Circle.web.js.map +1 -0
- package/lib/module/components/GroundOverlay.js +45 -0
- package/lib/module/components/GroundOverlay.js.map +1 -0
- package/lib/module/components/GroundOverlay.types.js +4 -0
- package/lib/module/components/GroundOverlay.types.js.map +1 -0
- package/lib/module/components/GroundOverlay.web.js +77 -0
- package/lib/module/components/GroundOverlay.web.js.map +1 -0
- package/lib/module/components/Marker.js +22 -4
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +20 -7
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/TileOverlay.js +44 -0
- package/lib/module/components/TileOverlay.js.map +1 -0
- package/lib/module/components/TileOverlay.types.js +4 -0
- package/lib/module/components/TileOverlay.types.js.map +1 -0
- package/lib/module/components/TileOverlay.web.js +69 -0
- package/lib/module/components/TileOverlay.web.js.map +1 -0
- package/lib/module/components/index.js +3 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +3 -0
- package/lib/module/components/index.web.js.map +1 -1
- package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/lib/module/fabric/LuggCircleViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
- package/lib/module/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/lib/module/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +3 -0
- package/lib/module/index.web.js.map +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.map +1 -1
- package/lib/typescript/src/components/Circle.d.ts +10 -0
- package/lib/typescript/src/components/Circle.d.ts.map +1 -0
- package/lib/typescript/src/components/Circle.types.d.ts +33 -0
- package/lib/typescript/src/components/Circle.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Circle.web.d.ts +3 -0
- package/lib/typescript/src/components/Circle.web.d.ts.map +1 -0
- package/lib/typescript/src/components/GroundOverlay.d.ts +10 -0
- package/lib/typescript/src/components/GroundOverlay.d.ts.map +1 -0
- package/lib/typescript/src/components/GroundOverlay.types.d.ts +35 -0
- package/lib/typescript/src/components/GroundOverlay.types.d.ts.map +1 -0
- package/lib/typescript/src/components/GroundOverlay.web.d.ts +3 -0
- package/lib/typescript/src/components/GroundOverlay.web.d.ts.map +1 -0
- 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 +18 -6
- 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/TileOverlay.d.ts +10 -0
- package/lib/typescript/src/components/TileOverlay.d.ts.map +1 -0
- package/lib/typescript/src/components/TileOverlay.types.d.ts +36 -0
- package/lib/typescript/src/components/TileOverlay.types.d.ts.map +1 -0
- package/lib/typescript/src/components/TileOverlay.web.d.ts +3 -0
- package/lib/typescript/src/components/TileOverlay.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +7 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +6 -0
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts +18 -0
- package/lib/typescript/src/fabric/LuggCircleViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts +21 -0
- package/lib/typescript/src/fabric/LuggGroundOverlayViewNativeComponent.d.ts.map +1 -0
- 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/fabric/LuggTileOverlayViewNativeComponent.d.ts +21 -0
- package/lib/typescript/src/fabric/LuggTileOverlayViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +7 -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 +5 -2
- package/src/MapView.tsx +11 -0
- package/src/MapView.types.ts +85 -1
- package/src/MapView.web.tsx +11 -0
- package/src/components/Circle.tsx +52 -0
- package/src/components/Circle.types.ts +33 -0
- package/src/components/Circle.web.tsx +93 -0
- package/src/components/GroundOverlay.tsx +47 -0
- package/src/components/GroundOverlay.types.ts +36 -0
- package/src/components/GroundOverlay.web.tsx +85 -0
- package/src/components/Marker.tsx +32 -6
- package/src/components/Marker.types.ts +19 -6
- package/src/components/Marker.web.tsx +191 -148
- package/src/components/TileOverlay.tsx +44 -0
- package/src/components/TileOverlay.types.ts +37 -0
- package/src/components/TileOverlay.web.tsx +95 -0
- package/src/components/index.ts +10 -0
- package/src/components/index.web.ts +9 -0
- package/src/fabric/LuggCalloutViewNativeComponent.ts +1 -1
- package/src/fabric/LuggCircleViewNativeComponent.ts +25 -0
- package/src/fabric/LuggGroundOverlayViewNativeComponent.ts +29 -0
- package/src/fabric/LuggMapViewNativeComponent.ts +9 -1
- package/src/fabric/LuggMarkerViewNativeComponent.ts +14 -2
- package/src/fabric/LuggTileOverlayViewNativeComponent.ts +30 -0
- package/src/index.ts +12 -1
- package/src/index.web.ts +15 -0
- package/src/types.ts +0 -5
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React, {
|
|
2
|
+
forwardRef,
|
|
2
3
|
isValidElement,
|
|
3
4
|
useCallback,
|
|
4
5
|
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
5
7
|
useRef,
|
|
6
8
|
useState,
|
|
7
9
|
} from 'react';
|
|
@@ -11,7 +13,7 @@ import {
|
|
|
11
13
|
useAdvancedMarkerRef,
|
|
12
14
|
} from '@vis.gl/react-google-maps';
|
|
13
15
|
import { useMapContext } from '../MapProvider.web';
|
|
14
|
-
import type { MarkerProps } from './Marker.types';
|
|
16
|
+
import type { MarkerProps, MarkerRef } from './Marker.types';
|
|
15
17
|
|
|
16
18
|
const CALLOUT_ARROW_HEIGHT = 12;
|
|
17
19
|
const UNBUBBLED_CLASS = 'rnm-callout-unbubbled';
|
|
@@ -58,153 +60,194 @@ const createEvent = (
|
|
|
58
60
|
},
|
|
59
61
|
} as any);
|
|
60
62
|
|
|
61
|
-
export const Marker = (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const [markerRef, markerElement] = useAdvancedMarkerRef();
|
|
81
|
-
const [infoWindowOpen, setInfoWindowOpen] = useState(false);
|
|
82
|
-
const calloutBubbled = calloutOptions?.bubbled ?? true;
|
|
83
|
-
|
|
84
|
-
const closeCallout = useCallback(() => setInfoWindowOpen(false), []);
|
|
85
|
-
|
|
86
|
-
useEffect(() => onCalloutClose(closeCallout), [onCalloutClose, closeCallout]);
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
if (!calloutBubbled) injectUnbubbledStyle();
|
|
90
|
-
}, [calloutBubbled]);
|
|
91
|
-
|
|
92
|
-
const hasCallout = !!(callout || title);
|
|
93
|
-
|
|
94
|
-
const calloutContent = callout
|
|
95
|
-
? isValidElement(callout)
|
|
96
|
-
? callout
|
|
97
|
-
: React.createElement(callout)
|
|
98
|
-
: title
|
|
99
|
-
? React.createElement(
|
|
100
|
-
'div',
|
|
101
|
-
{ style: { fontSize: 14 } },
|
|
102
|
-
React.createElement('div', { style: { fontWeight: 500 } }, title),
|
|
103
|
-
description ? React.createElement('div', null, description) : null
|
|
104
|
-
)
|
|
105
|
-
: null;
|
|
106
|
-
|
|
107
|
-
const transforms: string[] = [];
|
|
108
|
-
if (rotate) transforms.push(`rotate(${rotate}deg)`);
|
|
109
|
-
if (scale && scale !== 1) transforms.push(`scale(${scale})`);
|
|
110
|
-
|
|
111
|
-
const handleClick = useCallback(
|
|
112
|
-
(e: google.maps.MapMouseEvent) => {
|
|
113
|
-
const pos = dragPositionRef.current;
|
|
114
|
-
const coord = pos
|
|
115
|
-
? { latitude: pos.lat, longitude: pos.lng }
|
|
116
|
-
: coordinate;
|
|
117
|
-
moveCamera(coord);
|
|
118
|
-
onPress?.(createEvent(e, coordinate));
|
|
119
|
-
if (hasCallout) {
|
|
120
|
-
closeCallouts(closeCallout);
|
|
121
|
-
setInfoWindowOpen((prev) => !prev);
|
|
122
|
-
}
|
|
63
|
+
export const Marker = forwardRef<MarkerRef, MarkerProps>(
|
|
64
|
+
(
|
|
65
|
+
{
|
|
66
|
+
coordinate,
|
|
67
|
+
title,
|
|
68
|
+
description,
|
|
69
|
+
anchor,
|
|
70
|
+
zIndex,
|
|
71
|
+
rotate,
|
|
72
|
+
scale,
|
|
73
|
+
centerOnPress = true,
|
|
74
|
+
draggable,
|
|
75
|
+
onPress,
|
|
76
|
+
onDragStart,
|
|
77
|
+
onDragChange,
|
|
78
|
+
onDragEnd,
|
|
79
|
+
callout,
|
|
80
|
+
calloutOptions,
|
|
81
|
+
children,
|
|
123
82
|
},
|
|
124
|
-
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
83
|
+
ref
|
|
84
|
+
) => {
|
|
85
|
+
const { moveCamera, onCalloutClose, closeCallouts } = useMapContext();
|
|
86
|
+
const dragPositionRef = useRef<google.maps.LatLngLiteral | null>(null);
|
|
87
|
+
const [markerRef, markerElement] = useAdvancedMarkerRef();
|
|
88
|
+
const [infoWindowOpen, setInfoWindowOpen] = useState(false);
|
|
89
|
+
const calloutBubbled = calloutOptions?.bubbled ?? true;
|
|
90
|
+
const calloutOffset = calloutOptions?.offset;
|
|
91
|
+
|
|
92
|
+
const closeCallout = useCallback(() => setInfoWindowOpen(false), []);
|
|
93
|
+
|
|
94
|
+
useEffect(
|
|
95
|
+
() => onCalloutClose(closeCallout),
|
|
96
|
+
[onCalloutClose, closeCallout]
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (!calloutBubbled) injectUnbubbledStyle();
|
|
101
|
+
}, [calloutBubbled]);
|
|
102
|
+
|
|
103
|
+
const hasCallout = !!(callout || title);
|
|
104
|
+
|
|
105
|
+
useImperativeHandle(
|
|
106
|
+
ref,
|
|
107
|
+
() => ({
|
|
108
|
+
showCallout() {
|
|
109
|
+
if (hasCallout) {
|
|
110
|
+
closeCallouts(closeCallout);
|
|
111
|
+
setInfoWindowOpen(true);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
hideCallout() {
|
|
115
|
+
setInfoWindowOpen(false);
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
[hasCallout, closeCallouts, closeCallout]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const calloutContent = callout
|
|
122
|
+
? isValidElement(callout)
|
|
123
|
+
? callout
|
|
124
|
+
: React.createElement(callout)
|
|
125
|
+
: title
|
|
126
|
+
? React.createElement(
|
|
127
|
+
'div',
|
|
128
|
+
{ style: { fontSize: 14 } },
|
|
129
|
+
React.createElement('div', { style: { fontWeight: 500 } }, title),
|
|
130
|
+
description ? React.createElement('div', null, description) : null
|
|
131
|
+
)
|
|
132
|
+
: null;
|
|
133
|
+
|
|
134
|
+
const transforms: string[] = [];
|
|
135
|
+
if (rotate) transforms.push(`rotate(${rotate}deg)`);
|
|
136
|
+
if (scale && scale !== 1) transforms.push(`scale(${scale})`);
|
|
137
|
+
|
|
138
|
+
const handleClick = useCallback(
|
|
139
|
+
(e: google.maps.MapMouseEvent) => {
|
|
140
|
+
const pos = dragPositionRef.current;
|
|
141
|
+
const coord = pos
|
|
142
|
+
? { latitude: pos.lat, longitude: pos.lng }
|
|
143
|
+
: coordinate;
|
|
144
|
+
if (centerOnPress) moveCamera(coord);
|
|
145
|
+
onPress?.(createEvent(e, coordinate));
|
|
146
|
+
if (hasCallout) {
|
|
147
|
+
closeCallouts(closeCallout);
|
|
148
|
+
setInfoWindowOpen((prev) => !prev);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
[
|
|
152
|
+
centerOnPress,
|
|
153
|
+
moveCamera,
|
|
154
|
+
onPress,
|
|
155
|
+
coordinate,
|
|
156
|
+
hasCallout,
|
|
157
|
+
closeCallouts,
|
|
158
|
+
closeCallout,
|
|
159
|
+
]
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const handleDragStart = useCallback(
|
|
163
|
+
(e: google.maps.MapMouseEvent) => {
|
|
164
|
+
const latLng = e.latLng;
|
|
165
|
+
if (latLng) {
|
|
166
|
+
dragPositionRef.current = { lat: latLng.lat(), lng: latLng.lng() };
|
|
190
167
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
168
|
+
onDragStart?.(createEvent(e, coordinate));
|
|
169
|
+
},
|
|
170
|
+
[onDragStart, coordinate]
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const handleDrag = useCallback(
|
|
174
|
+
(e: google.maps.MapMouseEvent) => {
|
|
175
|
+
const latLng = e.latLng;
|
|
176
|
+
if (latLng) {
|
|
177
|
+
dragPositionRef.current = { lat: latLng.lat(), lng: latLng.lng() };
|
|
178
|
+
}
|
|
179
|
+
onDragChange?.(createEvent(e, coordinate));
|
|
180
|
+
},
|
|
181
|
+
[onDragChange, coordinate]
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const handleDragEnd = useCallback(
|
|
185
|
+
(e: google.maps.MapMouseEvent) => {
|
|
186
|
+
const latLng = e.latLng;
|
|
187
|
+
if (latLng) {
|
|
188
|
+
dragPositionRef.current = { lat: latLng.lat(), lng: latLng.lng() };
|
|
189
|
+
}
|
|
190
|
+
onDragEnd?.(createEvent(e, coordinate));
|
|
191
|
+
},
|
|
192
|
+
[onDragEnd, coordinate]
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
dragPositionRef.current = null;
|
|
197
|
+
}, [coordinate.latitude, coordinate.longitude]);
|
|
198
|
+
|
|
199
|
+
const latLngPosition = {
|
|
200
|
+
lat: coordinate.latitude,
|
|
201
|
+
lng: coordinate.longitude,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const position = dragPositionRef.current ?? latLngPosition;
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<>
|
|
208
|
+
<AdvancedMarker
|
|
209
|
+
ref={markerRef}
|
|
210
|
+
position={position}
|
|
211
|
+
title={title}
|
|
212
|
+
zIndex={zIndex}
|
|
213
|
+
anchorLeft={anchor ? toWebAnchor(anchor.x) : undefined}
|
|
214
|
+
anchorTop={anchor ? toWebAnchor(anchor.y) : undefined}
|
|
215
|
+
clickable
|
|
216
|
+
draggable={draggable}
|
|
217
|
+
onClick={handleClick}
|
|
218
|
+
onDragStart={handleDragStart}
|
|
219
|
+
onDrag={handleDrag}
|
|
220
|
+
onDragEnd={handleDragEnd}
|
|
221
|
+
style={
|
|
222
|
+
transforms.length > 0
|
|
223
|
+
? { transform: transforms.join(' ') }
|
|
224
|
+
: undefined
|
|
225
|
+
}
|
|
200
226
|
>
|
|
201
|
-
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
227
|
+
{children}
|
|
228
|
+
</AdvancedMarker>
|
|
229
|
+
{calloutContent && infoWindowOpen && markerElement && (
|
|
230
|
+
<InfoWindow
|
|
231
|
+
anchor={markerElement}
|
|
232
|
+
pixelOffset={
|
|
233
|
+
!calloutBubbled
|
|
234
|
+
? [
|
|
235
|
+
calloutOffset?.x ?? 0,
|
|
236
|
+
CALLOUT_ARROW_HEIGHT + (calloutOffset?.y ?? 0),
|
|
237
|
+
]
|
|
238
|
+
: undefined
|
|
239
|
+
}
|
|
240
|
+
headerDisabled
|
|
241
|
+
onClose={() => setInfoWindowOpen(false)}
|
|
242
|
+
>
|
|
243
|
+
{!calloutBubbled ? (
|
|
244
|
+
<div className={UNBUBBLED_CLASS}>{calloutContent}</div>
|
|
245
|
+
) : (
|
|
246
|
+
calloutContent
|
|
247
|
+
)}
|
|
248
|
+
</InfoWindow>
|
|
249
|
+
)}
|
|
250
|
+
</>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import LuggTileOverlayViewNativeComponent from '../fabric/LuggTileOverlayViewNativeComponent';
|
|
4
|
+
import type { TileOverlayProps } from './TileOverlay.types';
|
|
5
|
+
|
|
6
|
+
export type { TileOverlayProps } from './TileOverlay.types';
|
|
7
|
+
|
|
8
|
+
export class TileOverlay extends React.PureComponent<TileOverlayProps> {
|
|
9
|
+
private _cachedZIndex: number | undefined;
|
|
10
|
+
private _cachedStyle: any;
|
|
11
|
+
|
|
12
|
+
private getStyle(zIndex: number | undefined) {
|
|
13
|
+
if (zIndex == null) return styles.overlay;
|
|
14
|
+
if (zIndex !== this._cachedZIndex) {
|
|
15
|
+
this._cachedZIndex = zIndex;
|
|
16
|
+
this._cachedStyle = [{ zIndex }, styles.overlay];
|
|
17
|
+
}
|
|
18
|
+
return this._cachedStyle!;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
const { urlTemplate, tileSize, opacity, bounds, zIndex, onPress } =
|
|
23
|
+
this.props;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<LuggTileOverlayViewNativeComponent
|
|
27
|
+
style={this.getStyle(zIndex)}
|
|
28
|
+
urlTemplate={urlTemplate}
|
|
29
|
+
tileSize={tileSize}
|
|
30
|
+
opacity={opacity}
|
|
31
|
+
bounds={bounds}
|
|
32
|
+
tappable={!!onPress}
|
|
33
|
+
onTileOverlayPress={onPress}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const styles = StyleSheet.create({
|
|
40
|
+
overlay: {
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
pointerEvents: 'none',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Coordinate } from '../types';
|
|
2
|
+
|
|
3
|
+
export interface TileOverlayBounds {
|
|
4
|
+
northeast: Coordinate;
|
|
5
|
+
southwest: Coordinate;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TileOverlayProps {
|
|
9
|
+
/**
|
|
10
|
+
* URL template for tile images.
|
|
11
|
+
* Use `{x}`, `{y}`, `{z}` placeholders for tile coordinates and zoom level.
|
|
12
|
+
* @example "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
13
|
+
*/
|
|
14
|
+
urlTemplate: string;
|
|
15
|
+
/**
|
|
16
|
+
* Size of each tile in pixels
|
|
17
|
+
* @default 256
|
|
18
|
+
*/
|
|
19
|
+
tileSize?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Opacity of the tile overlay (0-1)
|
|
22
|
+
*/
|
|
23
|
+
opacity?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Restrict tiles to a geographic region.
|
|
26
|
+
* Tiles outside these bounds will not be loaded.
|
|
27
|
+
*/
|
|
28
|
+
bounds?: TileOverlayBounds;
|
|
29
|
+
/**
|
|
30
|
+
* Z-index for layering
|
|
31
|
+
*/
|
|
32
|
+
zIndex?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Called when the tile overlay is tapped
|
|
35
|
+
*/
|
|
36
|
+
onPress?: () => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useMapContext } from '../MapProvider.web';
|
|
3
|
+
import type { TileOverlayProps } from './TileOverlay.types';
|
|
4
|
+
|
|
5
|
+
export const TileOverlay = ({
|
|
6
|
+
urlTemplate,
|
|
7
|
+
tileSize = 256,
|
|
8
|
+
opacity = 1,
|
|
9
|
+
bounds,
|
|
10
|
+
zIndex = 0,
|
|
11
|
+
onPress,
|
|
12
|
+
}: TileOverlayProps) => {
|
|
13
|
+
const { map } = useMapContext();
|
|
14
|
+
const overlayRef = useRef<google.maps.ImageMapType | null>(null);
|
|
15
|
+
const indexRef = useRef<number>(-1);
|
|
16
|
+
|
|
17
|
+
const handleClick = useCallback(() => {
|
|
18
|
+
onPress?.();
|
|
19
|
+
}, [onPress]);
|
|
20
|
+
|
|
21
|
+
// Cleanup on unmount
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
return () => {
|
|
24
|
+
if (overlayRef.current && indexRef.current >= 0) {
|
|
25
|
+
map?.overlayMapTypes.removeAt(indexRef.current);
|
|
26
|
+
}
|
|
27
|
+
overlayRef.current = null;
|
|
28
|
+
indexRef.current = -1;
|
|
29
|
+
};
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
// Sync overlay with props
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!map) return;
|
|
36
|
+
|
|
37
|
+
// Remove old overlay
|
|
38
|
+
if (overlayRef.current && indexRef.current >= 0) {
|
|
39
|
+
map.overlayMapTypes.removeAt(indexRef.current);
|
|
40
|
+
overlayRef.current = null;
|
|
41
|
+
indexRef.current = -1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!urlTemplate) return;
|
|
45
|
+
|
|
46
|
+
const imageMapType = new google.maps.ImageMapType({
|
|
47
|
+
getTileUrl: (coord, zoom) => {
|
|
48
|
+
if (bounds) {
|
|
49
|
+
const n = Math.pow(2, zoom);
|
|
50
|
+
const tileSWLat =
|
|
51
|
+
(Math.atan(Math.sinh(Math.PI * (1 - (2 * (coord.y + 1)) / n))) *
|
|
52
|
+
180) /
|
|
53
|
+
Math.PI;
|
|
54
|
+
const tileNELat =
|
|
55
|
+
(Math.atan(Math.sinh(Math.PI * (1 - (2 * coord.y) / n))) * 180) /
|
|
56
|
+
Math.PI;
|
|
57
|
+
const tileSWLng = (coord.x / n) * 360 - 180;
|
|
58
|
+
const tileNELng = ((coord.x + 1) / n) * 360 - 180;
|
|
59
|
+
|
|
60
|
+
if (
|
|
61
|
+
tileNELat < bounds.southwest.latitude ||
|
|
62
|
+
tileSWLat > bounds.northeast.latitude ||
|
|
63
|
+
tileNELng < bounds.southwest.longitude ||
|
|
64
|
+
tileSWLng > bounds.northeast.longitude
|
|
65
|
+
) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return urlTemplate
|
|
71
|
+
.replace('{x}', String(coord.x))
|
|
72
|
+
.replace('{y}', String(coord.y))
|
|
73
|
+
.replace('{z}', String(zoom));
|
|
74
|
+
},
|
|
75
|
+
tileSize: new google.maps.Size(tileSize, tileSize),
|
|
76
|
+
opacity,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const length = map.overlayMapTypes.getLength();
|
|
80
|
+
map.overlayMapTypes.insertAt(length, imageMapType);
|
|
81
|
+
overlayRef.current = imageMapType;
|
|
82
|
+
indexRef.current = length;
|
|
83
|
+
}, [
|
|
84
|
+
map,
|
|
85
|
+
urlTemplate,
|
|
86
|
+
tileSize,
|
|
87
|
+
opacity,
|
|
88
|
+
bounds,
|
|
89
|
+
zIndex,
|
|
90
|
+
onPress,
|
|
91
|
+
handleClick,
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
return null;
|
|
95
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export { Marker } from './Marker';
|
|
2
2
|
export type {
|
|
3
3
|
CalloutOptions,
|
|
4
|
+
MarkerRef,
|
|
4
5
|
MarkerProps,
|
|
5
6
|
MarkerPressEvent,
|
|
6
7
|
MarkerDragEvent,
|
|
7
8
|
} from './Marker.types';
|
|
8
9
|
export { Polygon } from './Polygon';
|
|
9
10
|
export type { PolygonProps } from './Polygon.types';
|
|
11
|
+
export { Circle } from './Circle';
|
|
12
|
+
export type { CircleProps } from './Circle.types';
|
|
10
13
|
export { Polyline } from './Polyline';
|
|
11
14
|
export type {
|
|
12
15
|
PolylineProps,
|
|
@@ -15,3 +18,10 @@ export type {
|
|
|
15
18
|
} from './Polyline.types';
|
|
16
19
|
export { GeoJson } from './GeoJson';
|
|
17
20
|
export type { GeoJsonProps } from './GeoJson.types';
|
|
21
|
+
export { GroundOverlay } from './GroundOverlay';
|
|
22
|
+
export type {
|
|
23
|
+
GroundOverlayProps,
|
|
24
|
+
GroundOverlayBounds,
|
|
25
|
+
} from './GroundOverlay.types';
|
|
26
|
+
export { TileOverlay } from './TileOverlay';
|
|
27
|
+
export type { TileOverlayProps, TileOverlayBounds } from './TileOverlay.types';
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export { Marker } from './Marker.web';
|
|
2
2
|
export { Polygon } from './Polygon.web';
|
|
3
|
+
export { Circle } from './Circle.web';
|
|
3
4
|
export { Polyline } from './Polyline.web';
|
|
4
5
|
export type { CalloutOptions, MarkerProps } from './Marker.types';
|
|
5
6
|
export type { PolygonProps } from './Polygon.types';
|
|
7
|
+
export type { CircleProps } from './Circle.types';
|
|
6
8
|
export type { PolylineProps } from './Polyline.types';
|
|
7
9
|
export { GeoJson } from './GeoJson';
|
|
8
10
|
export type { GeoJsonProps } from './GeoJson.types';
|
|
11
|
+
export { GroundOverlay } from './GroundOverlay.web';
|
|
12
|
+
export type {
|
|
13
|
+
GroundOverlayProps,
|
|
14
|
+
GroundOverlayBounds,
|
|
15
|
+
} from './GroundOverlay.types';
|
|
16
|
+
export { TileOverlay } from './TileOverlay.web';
|
|
17
|
+
export type { TileOverlayProps, TileOverlayBounds } from './TileOverlay.types';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { codegenNativeComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent, ColorValue } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
DirectEventHandler,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export interface Coordinate {
|
|
9
|
+
latitude: Double;
|
|
10
|
+
longitude: Double;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface NativeProps extends ViewProps {
|
|
14
|
+
center: Coordinate;
|
|
15
|
+
radius?: Double;
|
|
16
|
+
strokeColor?: ColorValue;
|
|
17
|
+
strokeWidth?: Double;
|
|
18
|
+
fillColor?: ColorValue;
|
|
19
|
+
tappable?: boolean;
|
|
20
|
+
onCirclePress?: DirectEventHandler<null>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default codegenNativeComponent<NativeProps>(
|
|
24
|
+
'LuggCircleView'
|
|
25
|
+
) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { codegenNativeComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
DirectEventHandler,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export interface Coordinate {
|
|
9
|
+
latitude: Double;
|
|
10
|
+
longitude: Double;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Bounds {
|
|
14
|
+
northeast: Coordinate;
|
|
15
|
+
southwest: Coordinate;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface NativeProps extends ViewProps {
|
|
19
|
+
image: string;
|
|
20
|
+
bounds: Bounds;
|
|
21
|
+
opacity?: Double;
|
|
22
|
+
bearing?: Double;
|
|
23
|
+
tappable?: boolean;
|
|
24
|
+
onGroundOverlayPress?: DirectEventHandler<null>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default codegenNativeComponent<NativeProps>(
|
|
28
|
+
'LuggGroundOverlayView'
|
|
29
|
+
) as HostComponent<NativeProps>;
|
|
@@ -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>;
|