@lugg/maps 0.2.0-alpha.14 → 0.2.0-alpha.15
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from 'react';
|
|
4
|
-
import { View } from 'react-native';
|
|
4
|
+
import { View, StyleSheet } from 'react-native';
|
|
5
5
|
import { Map, useMap } from '@vis.gl/react-google-maps';
|
|
6
6
|
import { Marker } from "./components/Marker.web.js";
|
|
7
7
|
import { MapIdContext } from "./MapProvider.web.js";
|
|
@@ -88,6 +88,8 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
88
88
|
const id = useId();
|
|
89
89
|
const map = useMap(id);
|
|
90
90
|
const readyFired = useRef(false);
|
|
91
|
+
const isDragging = useRef(false);
|
|
92
|
+
const wasGesture = useRef(false);
|
|
91
93
|
useImperativeHandle(ref, () => ({
|
|
92
94
|
moveCamera(coordinate, options) {
|
|
93
95
|
if (!map) return;
|
|
@@ -148,48 +150,43 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
148
150
|
onReady?.();
|
|
149
151
|
}
|
|
150
152
|
}, [map, onReady]);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
153
|
+
const handleDragStart = () => {
|
|
154
|
+
isDragging.current = true;
|
|
155
|
+
wasGesture.current = true;
|
|
156
|
+
};
|
|
157
|
+
const handleDragEnd = () => {
|
|
158
|
+
isDragging.current = false;
|
|
159
|
+
};
|
|
160
|
+
const handleCameraChanged = event => {
|
|
161
|
+
const payload = {
|
|
162
|
+
coordinate: {
|
|
163
|
+
latitude: event.detail.center.lat,
|
|
164
|
+
longitude: event.detail.center.lng
|
|
165
|
+
},
|
|
166
|
+
zoom: event.detail.zoom,
|
|
167
|
+
gesture: isDragging.current
|
|
163
168
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
const idleListener = map.addListener('idle', () => {
|
|
177
|
-
onCameraIdle?.(createSyntheticEvent(createPayload(wasGesture)));
|
|
178
|
-
wasGesture = false;
|
|
179
|
-
});
|
|
180
|
-
return () => {
|
|
181
|
-
google.maps.event.removeListener(dragStartListener);
|
|
182
|
-
google.maps.event.removeListener(dragEndListener);
|
|
183
|
-
google.maps.event.removeListener(centerListener);
|
|
184
|
-
google.maps.event.removeListener(idleListener);
|
|
169
|
+
onCameraMove?.(createSyntheticEvent(payload));
|
|
170
|
+
};
|
|
171
|
+
const handleIdle = event => {
|
|
172
|
+
const center = event.map.getCenter();
|
|
173
|
+
const payload = {
|
|
174
|
+
coordinate: {
|
|
175
|
+
latitude: center?.lat() ?? 0,
|
|
176
|
+
longitude: center?.lng() ?? 0
|
|
177
|
+
},
|
|
178
|
+
zoom: event.map.getZoom() ?? 0,
|
|
179
|
+
gesture: wasGesture.current
|
|
185
180
|
};
|
|
186
|
-
|
|
181
|
+
onCameraIdle?.(createSyntheticEvent(payload));
|
|
182
|
+
wasGesture.current = false;
|
|
183
|
+
};
|
|
187
184
|
const gestureHandling = scrollEnabled === false && zoomEnabled === false ? 'none' : scrollEnabled === false ? 'cooperative' : 'auto';
|
|
188
185
|
const defaultCenter = initialCoordinate ? {
|
|
189
186
|
lat: initialCoordinate.latitude,
|
|
190
187
|
lng: initialCoordinate.longitude
|
|
191
188
|
} : undefined;
|
|
192
|
-
const
|
|
189
|
+
const paddingStyle = {
|
|
193
190
|
paddingTop: padding?.top ?? 0,
|
|
194
191
|
paddingLeft: padding?.left ?? 0,
|
|
195
192
|
paddingRight: padding?.right ?? 0,
|
|
@@ -199,20 +196,27 @@ export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
|
199
196
|
value: id,
|
|
200
197
|
children: /*#__PURE__*/_jsx(View, {
|
|
201
198
|
style: style,
|
|
202
|
-
children: /*#__PURE__*/
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
199
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
200
|
+
style: [StyleSheet.absoluteFill, paddingStyle],
|
|
201
|
+
children: /*#__PURE__*/_jsxs(Map, {
|
|
202
|
+
id: id,
|
|
203
|
+
mapId: mapId,
|
|
204
|
+
defaultCenter: defaultCenter,
|
|
205
|
+
defaultZoom: initialZoom,
|
|
206
|
+
minZoom: minZoom,
|
|
207
|
+
maxZoom: maxZoom,
|
|
208
|
+
gestureHandling: gestureHandling,
|
|
209
|
+
disableDefaultUI: true,
|
|
210
|
+
isFractionalZoomEnabled: true,
|
|
211
|
+
tilt: pitchEnabled === false ? 0 : undefined,
|
|
212
|
+
onDragstart: handleDragStart,
|
|
213
|
+
onDragend: handleDragEnd,
|
|
214
|
+
onCameraChanged: handleCameraChanged,
|
|
215
|
+
onIdle: handleIdle,
|
|
216
|
+
children: [/*#__PURE__*/_jsx(UserLocationMarker, {
|
|
217
|
+
enabled: userLocationEnabled
|
|
218
|
+
}), children]
|
|
219
|
+
})
|
|
216
220
|
})
|
|
217
221
|
})
|
|
218
222
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useEffect","useId","useImperativeHandle","useRef","useState","View","Map","useMap","Marker","MapIdContext","jsx","_jsx","jsxs","_jsxs","createSyntheticEvent","nativeEvent","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","preventDefault","stopPropagation","isDefaultPrevented","isPropagationStopped","persist","timeStamp","Date","now","type","userLocationDotStyle","width","height","backgroundColor","border","borderRadius","boxShadow","UserLocationMarker","enabled","coordinate","setCoordinate","watchId","updateLocation","position","latitude","coords","longitude","navigator","geolocation","getCurrentPosition","watchPosition","clearWatch","anchor","x","y","children","style","MapView","props","ref","mapId","google","maps","DEMO_MAP_ID","initialCoordinate","initialZoom","minZoom","maxZoom","zoomEnabled","scrollEnabled","pitchEnabled","padding","userLocationEnabled","onCameraMove","onCameraIdle","onReady","id","map","readyFired","moveCamera","options","zoom","duration","center","lat","lng","currentZoom","getZoom","zoomChanged","undefined","setZoom","panTo","fitCoordinates","coordinates","first","fitPadding","length","bounds","LatLngBounds","forEach","coord","extend","fitBounds","top","left","bottom","right","current","
|
|
1
|
+
{"version":3,"names":["forwardRef","useEffect","useId","useImperativeHandle","useRef","useState","View","StyleSheet","Map","useMap","Marker","MapIdContext","jsx","_jsx","jsxs","_jsxs","createSyntheticEvent","nativeEvent","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","preventDefault","stopPropagation","isDefaultPrevented","isPropagationStopped","persist","timeStamp","Date","now","type","userLocationDotStyle","width","height","backgroundColor","border","borderRadius","boxShadow","UserLocationMarker","enabled","coordinate","setCoordinate","watchId","updateLocation","position","latitude","coords","longitude","navigator","geolocation","getCurrentPosition","watchPosition","clearWatch","anchor","x","y","children","style","MapView","props","ref","mapId","google","maps","DEMO_MAP_ID","initialCoordinate","initialZoom","minZoom","maxZoom","zoomEnabled","scrollEnabled","pitchEnabled","padding","userLocationEnabled","onCameraMove","onCameraIdle","onReady","id","map","readyFired","isDragging","wasGesture","moveCamera","options","zoom","duration","center","lat","lng","currentZoom","getZoom","zoomChanged","undefined","setZoom","panTo","fitCoordinates","coordinates","first","fitPadding","length","bounds","LatLngBounds","forEach","coord","extend","fitBounds","top","left","bottom","right","current","handleDragStart","handleDragEnd","handleCameraChanged","event","payload","detail","gesture","handleIdle","getCenter","gestureHandling","defaultCenter","paddingStyle","paddingTop","paddingLeft","paddingRight","paddingBottom","Provider","value","absoluteFill","defaultZoom","disableDefaultUI","isFractionalZoomEnabled","tilt","onDragstart","onDragend","onCameraChanged","onIdle"],"sourceRoot":"../../src","sources":["MapView.web.tsx"],"mappings":";;AAAA,SACEA,UAAU,EACVC,SAAS,EACTC,KAAK,EACLC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QAEH,OAAO;AAEd,SAASC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAC/C,SACEC,GAAG,EACHC,MAAM,QAGD,2BAA2B;AAClC,SAASC,MAAM,QAAQ,4BAAyB;AAChD,SAASC,YAAY,QAAQ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAWjD,MAAMC,oBAAoB,GAAQC,WAAc,KAC7C;EACCA,WAAW;EACXC,aAAa,EAAE,IAAI;EACnBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAE,KAAK;EACdC,UAAU,EAAE,KAAK;EACjBC,gBAAgB,EAAE,KAAK;EACvBC,UAAU,EAAE,CAAC;EACbC,SAAS,EAAE,IAAI;EACfC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;EACxBC,eAAe,EAAEA,CAAA,KAAM,CAAC,CAAC;EACzBC,kBAAkB,EAAEA,CAAA,KAAM,KAAK;EAC/BC,oBAAoB,EAAEA,CAAA,KAAM,KAAK;EACjCC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBC,SAAS,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC;EACrBC,IAAI,EAAE;AACR,CAAC,CAAuC;AAE1C,MAAMC,oBAAmC,GAAG;EAC1CC,KAAK,EAAE,EAAE;EACTC,MAAM,EAAE,EAAE;EACVC,eAAe,EAAE,SAAS;EAC1BC,MAAM,EAAE,iBAAiB;EACzBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAE;AACb,CAAC;AAED,SAASC,kBAA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nDjB,QAAQ;QAAA,CACN;MAAC,CACF;IAAC,CACH;EAAC,CACc,CAAC;AAE5B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapView.web.d.ts","sourceRoot":"","sources":["../../../src/MapView.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapView.web.d.ts","sourceRoot":"","sources":["../../../src/MapView.web.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAIX,MAAM,iBAAiB,CAAC;AAoEzB,eAAO,MAAM,OAAO,qGAuKlB,CAAC"}
|
package/package.json
CHANGED
package/src/MapView.web.tsx
CHANGED
|
@@ -7,9 +7,14 @@ import {
|
|
|
7
7
|
useState,
|
|
8
8
|
type CSSProperties,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import type { NativeSyntheticEvent } from 'react-native';
|
|
11
|
-
import { View } from 'react-native';
|
|
12
|
-
import {
|
|
10
|
+
import type { NativeSyntheticEvent, ViewStyle } from 'react-native';
|
|
11
|
+
import { View, StyleSheet } from 'react-native';
|
|
12
|
+
import {
|
|
13
|
+
Map,
|
|
14
|
+
useMap,
|
|
15
|
+
type MapCameraChangedEvent,
|
|
16
|
+
type MapEvent,
|
|
17
|
+
} from '@vis.gl/react-google-maps';
|
|
13
18
|
import { Marker } from './components/Marker.web';
|
|
14
19
|
import { MapIdContext } from './MapProvider.web';
|
|
15
20
|
|
|
@@ -112,6 +117,8 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
112
117
|
const id = useId();
|
|
113
118
|
const map = useMap(id);
|
|
114
119
|
const readyFired = useRef(false);
|
|
120
|
+
const isDragging = useRef(false);
|
|
121
|
+
const wasGesture = useRef(false);
|
|
115
122
|
|
|
116
123
|
useImperativeHandle(
|
|
117
124
|
ref,
|
|
@@ -172,49 +179,40 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
172
179
|
}
|
|
173
180
|
}, [map, onReady]);
|
|
174
181
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const center = map.getCenter();
|
|
180
|
-
return {
|
|
181
|
-
coordinate: {
|
|
182
|
-
latitude: center?.lat() ?? 0,
|
|
183
|
-
longitude: center?.lng() ?? 0,
|
|
184
|
-
},
|
|
185
|
-
zoom: map.getZoom() ?? 0,
|
|
186
|
-
gesture,
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
let isDragging = false;
|
|
191
|
-
let wasGesture = false;
|
|
192
|
-
|
|
193
|
-
const dragStartListener = map.addListener('dragstart', () => {
|
|
194
|
-
isDragging = true;
|
|
195
|
-
wasGesture = true;
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
const dragEndListener = map.addListener('dragend', () => {
|
|
199
|
-
isDragging = false;
|
|
200
|
-
});
|
|
182
|
+
const handleDragStart = () => {
|
|
183
|
+
isDragging.current = true;
|
|
184
|
+
wasGesture.current = true;
|
|
185
|
+
};
|
|
201
186
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
187
|
+
const handleDragEnd = () => {
|
|
188
|
+
isDragging.current = false;
|
|
189
|
+
};
|
|
205
190
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
191
|
+
const handleCameraChanged = (event: MapCameraChangedEvent) => {
|
|
192
|
+
const payload: CameraEventPayload = {
|
|
193
|
+
coordinate: {
|
|
194
|
+
latitude: event.detail.center.lat,
|
|
195
|
+
longitude: event.detail.center.lng,
|
|
196
|
+
},
|
|
197
|
+
zoom: event.detail.zoom,
|
|
198
|
+
gesture: isDragging.current,
|
|
199
|
+
};
|
|
200
|
+
onCameraMove?.(createSyntheticEvent(payload));
|
|
201
|
+
};
|
|
210
202
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
203
|
+
const handleIdle = (event: MapEvent) => {
|
|
204
|
+
const center = event.map.getCenter();
|
|
205
|
+
const payload: CameraEventPayload = {
|
|
206
|
+
coordinate: {
|
|
207
|
+
latitude: center?.lat() ?? 0,
|
|
208
|
+
longitude: center?.lng() ?? 0,
|
|
209
|
+
},
|
|
210
|
+
zoom: event.map.getZoom() ?? 0,
|
|
211
|
+
gesture: wasGesture.current,
|
|
216
212
|
};
|
|
217
|
-
|
|
213
|
+
onCameraIdle?.(createSyntheticEvent(payload));
|
|
214
|
+
wasGesture.current = false;
|
|
215
|
+
};
|
|
218
216
|
|
|
219
217
|
const gestureHandling =
|
|
220
218
|
scrollEnabled === false && zoomEnabled === false
|
|
@@ -227,7 +225,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
227
225
|
? { lat: initialCoordinate.latitude, lng: initialCoordinate.longitude }
|
|
228
226
|
: undefined;
|
|
229
227
|
|
|
230
|
-
const
|
|
228
|
+
const paddingStyle: ViewStyle = {
|
|
231
229
|
paddingTop: padding?.top ?? 0,
|
|
232
230
|
paddingLeft: padding?.left ?? 0,
|
|
233
231
|
paddingRight: padding?.right ?? 0,
|
|
@@ -237,21 +235,27 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
|
237
235
|
return (
|
|
238
236
|
<MapIdContext.Provider value={id}>
|
|
239
237
|
<View style={style}>
|
|
240
|
-
<
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
238
|
+
<View style={[StyleSheet.absoluteFill, paddingStyle]}>
|
|
239
|
+
<Map
|
|
240
|
+
id={id}
|
|
241
|
+
mapId={mapId}
|
|
242
|
+
defaultCenter={defaultCenter}
|
|
243
|
+
defaultZoom={initialZoom}
|
|
244
|
+
minZoom={minZoom}
|
|
245
|
+
maxZoom={maxZoom}
|
|
246
|
+
gestureHandling={gestureHandling}
|
|
247
|
+
disableDefaultUI
|
|
248
|
+
isFractionalZoomEnabled
|
|
249
|
+
tilt={pitchEnabled === false ? 0 : undefined}
|
|
250
|
+
onDragstart={handleDragStart}
|
|
251
|
+
onDragend={handleDragEnd}
|
|
252
|
+
onCameraChanged={handleCameraChanged}
|
|
253
|
+
onIdle={handleIdle}
|
|
254
|
+
>
|
|
255
|
+
<UserLocationMarker enabled={userLocationEnabled} />
|
|
256
|
+
{children}
|
|
257
|
+
</Map>
|
|
258
|
+
</View>
|
|
255
259
|
</View>
|
|
256
260
|
</MapIdContext.Provider>
|
|
257
261
|
);
|