@lugg/maps 0.2.0-alpha.10 → 0.2.0-alpha.11
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/lib/module/MapView.web.js +124 -155
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/Marker.web.js +16 -25
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polyline.web.js +2 -10
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +2 -11
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +1 -4
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts +1 -4
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapView.web.tsx +133 -169
- package/src/components/Marker.web.tsx +18 -26
- package/src/components/Polyline.web.tsx +2 -15
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Children,
|
|
3
|
+
import { Children, forwardRef, isValidElement, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
4
4
|
import { View } 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 { Polyline } from "./components/Polyline.web.js";
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
// Map-specific component types that render inside the Google Map
|
|
10
9
|
const MAP_COMPONENT_TYPES = new Set([Marker, Polyline]);
|
|
11
10
|
const isMapComponent = child => MAP_COMPONENT_TYPES.has(child.type);
|
|
12
11
|
const createSyntheticEvent = nativeEvent => ({
|
|
@@ -70,22 +69,86 @@ function UserLocationMarker({
|
|
|
70
69
|
})
|
|
71
70
|
});
|
|
72
71
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
export const MapView = /*#__PURE__*/forwardRef(function MapView(props, ref) {
|
|
73
|
+
const {
|
|
74
|
+
mapId = 'DEMO_MAP_ID',
|
|
75
|
+
initialCoordinate,
|
|
76
|
+
initialZoom = 10,
|
|
77
|
+
minZoom,
|
|
78
|
+
maxZoom,
|
|
79
|
+
zoomEnabled = true,
|
|
80
|
+
scrollEnabled = true,
|
|
81
|
+
pitchEnabled = true,
|
|
82
|
+
padding,
|
|
83
|
+
userLocationEnabled,
|
|
84
|
+
onCameraMove,
|
|
85
|
+
onCameraIdle,
|
|
86
|
+
onReady,
|
|
87
|
+
children,
|
|
88
|
+
style
|
|
89
|
+
} = props;
|
|
79
90
|
const map = useMap();
|
|
80
91
|
const readyFired = useRef(false);
|
|
92
|
+
useImperativeHandle(ref, () => ({
|
|
93
|
+
moveCamera(coordinate, options) {
|
|
94
|
+
if (!map) return;
|
|
95
|
+
const {
|
|
96
|
+
zoom,
|
|
97
|
+
duration = -1
|
|
98
|
+
} = options;
|
|
99
|
+
const center = {
|
|
100
|
+
lat: coordinate.latitude,
|
|
101
|
+
lng: coordinate.longitude
|
|
102
|
+
};
|
|
103
|
+
if (duration === 0) {
|
|
104
|
+
map.moveCamera({
|
|
105
|
+
center,
|
|
106
|
+
zoom
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
const currentZoom = map.getZoom();
|
|
110
|
+
const zoomChanged = zoom !== undefined && zoom !== currentZoom;
|
|
111
|
+
if (zoomChanged) {
|
|
112
|
+
map.setZoom(zoom);
|
|
113
|
+
}
|
|
114
|
+
map.panTo(center);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
fitCoordinates(coordinates, options) {
|
|
118
|
+
const first = coordinates[0];
|
|
119
|
+
if (!map || !first) return;
|
|
120
|
+
const {
|
|
121
|
+
padding: fitPadding,
|
|
122
|
+
duration = -1
|
|
123
|
+
} = options ?? {};
|
|
124
|
+
if (coordinates.length === 1) {
|
|
125
|
+
this.moveCamera(first, {
|
|
126
|
+
zoom: initialZoom,
|
|
127
|
+
duration
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const bounds = new google.maps.LatLngBounds();
|
|
132
|
+
coordinates.forEach(coord => {
|
|
133
|
+
bounds.extend({
|
|
134
|
+
lat: coord.latitude,
|
|
135
|
+
lng: coord.longitude
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
map.fitBounds(bounds, {
|
|
139
|
+
top: fitPadding?.top ?? 0,
|
|
140
|
+
left: fitPadding?.left ?? 0,
|
|
141
|
+
bottom: fitPadding?.bottom ?? 0,
|
|
142
|
+
right: fitPadding?.right ?? 0
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}), [map, initialZoom]);
|
|
81
146
|
useEffect(() => {
|
|
82
|
-
if (!
|
|
83
|
-
onMapReady(map);
|
|
84
|
-
if (!readyFired.current) {
|
|
147
|
+
if (map && !readyFired.current) {
|
|
85
148
|
readyFired.current = true;
|
|
86
149
|
onReady?.();
|
|
87
150
|
}
|
|
88
|
-
}, [map,
|
|
151
|
+
}, [map, onReady]);
|
|
89
152
|
useEffect(() => {
|
|
90
153
|
if (!map) return;
|
|
91
154
|
const createPayload = gesture => {
|
|
@@ -100,8 +163,10 @@ function MapController({
|
|
|
100
163
|
};
|
|
101
164
|
};
|
|
102
165
|
let isDragging = false;
|
|
166
|
+
let wasGesture = false;
|
|
103
167
|
const dragStartListener = map.addListener('dragstart', () => {
|
|
104
168
|
isDragging = true;
|
|
169
|
+
wasGesture = true;
|
|
105
170
|
});
|
|
106
171
|
const dragEndListener = map.addListener('dragend', () => {
|
|
107
172
|
isDragging = false;
|
|
@@ -110,7 +175,8 @@ function MapController({
|
|
|
110
175
|
onCameraMove?.(createSyntheticEvent(createPayload(isDragging)));
|
|
111
176
|
});
|
|
112
177
|
const idleListener = map.addListener('idle', () => {
|
|
113
|
-
onCameraIdle?.(createSyntheticEvent(createPayload(
|
|
178
|
+
onCameraIdle?.(createSyntheticEvent(createPayload(wasGesture)));
|
|
179
|
+
wasGesture = false;
|
|
114
180
|
});
|
|
115
181
|
return () => {
|
|
116
182
|
google.maps.event.removeListener(dragStartListener);
|
|
@@ -119,148 +185,51 @@ function MapController({
|
|
|
119
185
|
google.maps.event.removeListener(idleListener);
|
|
120
186
|
};
|
|
121
187
|
}, [map, onCameraMove, onCameraIdle]);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
mapInstance = null;
|
|
135
|
-
handleMapReady = map => {
|
|
136
|
-
this.mapInstance = map;
|
|
137
|
-
};
|
|
138
|
-
moveCamera(coordinate, options) {
|
|
139
|
-
const map = this.mapInstance;
|
|
140
|
-
if (!map) return;
|
|
141
|
-
const {
|
|
142
|
-
zoom,
|
|
143
|
-
duration = -1
|
|
144
|
-
} = options;
|
|
145
|
-
const center = {
|
|
146
|
-
lat: coordinate.latitude,
|
|
147
|
-
lng: coordinate.longitude
|
|
148
|
-
};
|
|
149
|
-
if (duration === 0) {
|
|
150
|
-
map.moveCamera({
|
|
151
|
-
center,
|
|
152
|
-
zoom
|
|
153
|
-
});
|
|
188
|
+
const gestureHandling = scrollEnabled === false && zoomEnabled === false ? 'none' : scrollEnabled === false ? 'none' : 'auto';
|
|
189
|
+
const defaultCenter = initialCoordinate ? {
|
|
190
|
+
lat: initialCoordinate.latitude,
|
|
191
|
+
lng: initialCoordinate.longitude
|
|
192
|
+
} : undefined;
|
|
193
|
+
const mapChildren = [];
|
|
194
|
+
const overlayChildren = [];
|
|
195
|
+
Children.forEach(children, child => {
|
|
196
|
+
if (! /*#__PURE__*/isValidElement(child)) return;
|
|
197
|
+
if (isMapComponent(child)) {
|
|
198
|
+
mapChildren.push(child);
|
|
154
199
|
} else {
|
|
155
|
-
|
|
156
|
-
const zoomChanged = zoom !== undefined && zoom !== currentZoom;
|
|
157
|
-
if (zoomChanged) {
|
|
158
|
-
map.setZoom(zoom);
|
|
159
|
-
}
|
|
160
|
-
map.panTo(center);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
fitCoordinates(coordinates, options) {
|
|
164
|
-
const map = this.mapInstance;
|
|
165
|
-
const first = coordinates[0];
|
|
166
|
-
if (!map || !first) return;
|
|
167
|
-
const {
|
|
168
|
-
padding,
|
|
169
|
-
duration = -1
|
|
170
|
-
} = options ?? {};
|
|
171
|
-
if (coordinates.length === 1) {
|
|
172
|
-
const zoom = this.props.initialZoom ?? 10;
|
|
173
|
-
this.moveCamera(first, {
|
|
174
|
-
zoom,
|
|
175
|
-
duration
|
|
176
|
-
});
|
|
177
|
-
return;
|
|
200
|
+
overlayChildren.push(child);
|
|
178
201
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const defaultCenter = initialCoordinate ? {
|
|
213
|
-
lat: initialCoordinate.latitude,
|
|
214
|
-
lng: initialCoordinate.longitude
|
|
215
|
-
} : undefined;
|
|
216
|
-
|
|
217
|
-
// Separate map children (Marker, Polyline) from overlay children (regular Views)
|
|
218
|
-
const mapChildren = [];
|
|
219
|
-
const overlayChildren = [];
|
|
220
|
-
Children.forEach(children, child => {
|
|
221
|
-
if (! /*#__PURE__*/isValidElement(child)) return;
|
|
222
|
-
if (isMapComponent(child)) {
|
|
223
|
-
mapChildren.push(child);
|
|
224
|
-
} else {
|
|
225
|
-
overlayChildren.push(child);
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
const mapContainerStyle = {
|
|
229
|
-
position: 'absolute',
|
|
230
|
-
top: padding?.top ?? 0,
|
|
231
|
-
left: padding?.left ?? 0,
|
|
232
|
-
right: padding?.right ?? 0,
|
|
233
|
-
bottom: padding?.bottom ?? 0
|
|
234
|
-
};
|
|
235
|
-
const mapStyle = {
|
|
236
|
-
width: '100%',
|
|
237
|
-
height: '100%'
|
|
238
|
-
};
|
|
239
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
240
|
-
style: style,
|
|
241
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
242
|
-
style: mapContainerStyle,
|
|
243
|
-
children: /*#__PURE__*/_jsxs(Map, {
|
|
244
|
-
mapId: mapId,
|
|
245
|
-
defaultCenter: defaultCenter,
|
|
246
|
-
defaultZoom: initialZoom,
|
|
247
|
-
minZoom: minZoom,
|
|
248
|
-
maxZoom: maxZoom,
|
|
249
|
-
gestureHandling: gestureHandling,
|
|
250
|
-
disableDefaultUI: true,
|
|
251
|
-
tilt: pitchEnabled === false ? 0 : undefined,
|
|
252
|
-
style: mapStyle,
|
|
253
|
-
children: [/*#__PURE__*/_jsx(MapController, {
|
|
254
|
-
onMapReady: this.handleMapReady,
|
|
255
|
-
onCameraMove: onCameraMove,
|
|
256
|
-
onCameraIdle: onCameraIdle,
|
|
257
|
-
onReady: onReady
|
|
258
|
-
}), /*#__PURE__*/_jsx(UserLocationMarker, {
|
|
259
|
-
enabled: userLocationEnabled
|
|
260
|
-
}), mapChildren]
|
|
261
|
-
})
|
|
262
|
-
}), overlayChildren]
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}
|
|
202
|
+
});
|
|
203
|
+
const mapContainerStyle = {
|
|
204
|
+
position: 'absolute',
|
|
205
|
+
top: padding?.top ?? 0,
|
|
206
|
+
left: padding?.left ?? 0,
|
|
207
|
+
right: padding?.right ?? 0,
|
|
208
|
+
bottom: padding?.bottom ?? 0
|
|
209
|
+
};
|
|
210
|
+
const mapStyle = {
|
|
211
|
+
width: '100%',
|
|
212
|
+
height: '100%'
|
|
213
|
+
};
|
|
214
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
215
|
+
style: style,
|
|
216
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
217
|
+
style: mapContainerStyle,
|
|
218
|
+
children: /*#__PURE__*/_jsxs(Map, {
|
|
219
|
+
mapId: mapId,
|
|
220
|
+
defaultCenter: defaultCenter,
|
|
221
|
+
defaultZoom: initialZoom,
|
|
222
|
+
minZoom: minZoom,
|
|
223
|
+
maxZoom: maxZoom,
|
|
224
|
+
gestureHandling: gestureHandling,
|
|
225
|
+
disableDefaultUI: true,
|
|
226
|
+
tilt: pitchEnabled === false ? 0 : undefined,
|
|
227
|
+
style: mapStyle,
|
|
228
|
+
children: [/*#__PURE__*/_jsx(UserLocationMarker, {
|
|
229
|
+
enabled: userLocationEnabled
|
|
230
|
+
}), mapChildren]
|
|
231
|
+
})
|
|
232
|
+
}), overlayChildren]
|
|
233
|
+
});
|
|
234
|
+
});
|
|
266
235
|
//# sourceMappingURL=MapView.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Children","
|
|
1
|
+
{"version":3,"names":["Children","forwardRef","isValidElement","useEffect","useImperativeHandle","useRef","useState","View","Map","useMap","Marker","Polyline","jsx","_jsx","jsxs","_jsxs","MAP_COMPONENT_TYPES","Set","isMapComponent","child","has","type","createSyntheticEvent","nativeEvent","currentTarget","target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","preventDefault","stopPropagation","isDefaultPrevented","isPropagationStopped","persist","timeStamp","Date","now","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","initialCoordinate","initialZoom","minZoom","maxZoom","zoomEnabled","scrollEnabled","pitchEnabled","padding","userLocationEnabled","onCameraMove","onCameraIdle","onReady","map","readyFired","moveCamera","options","zoom","duration","center","lat","lng","currentZoom","getZoom","zoomChanged","undefined","setZoom","panTo","fitCoordinates","coordinates","first","fitPadding","length","bounds","google","maps","LatLngBounds","forEach","coord","extend","fitBounds","top","left","bottom","right","current","createPayload","gesture","getCenter","isDragging","wasGesture","dragStartListener","addListener","dragEndListener","centerListener","idleListener","event","removeListener","gestureHandling","defaultCenter","mapChildren","overlayChildren","push","mapContainerStyle","mapStyle","defaultZoom","disableDefaultUI","tilt"],"sourceRoot":"../../src","sources":["MapView.web.tsx"],"mappings":";;AAAA,SACEA,QAAQ,EACRC,UAAU,EACVC,cAAc,EACdC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QAIH,OAAO;AAEd,SAASC,IAAI,QAAQ,cAAc;AACnC,SAASC,GAAG,EAAEC,MAAM,QAAQ,2BAA2B;AACvD,SAASC,MAAM,QAAQ,4BAAyB;AAChD,SAASC,QAAQ,QAAQ,8BAA2B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAWrD,MAAMC,mBAAmB,GAAG,IAAIC,GAAG,CAAC,CAACP,MAAM,EAAEC,QAAQ,CAAC,CAAC;AAEvD,MAAMO,cAAc,GAAIC,KAAmB,IACzCH,mBAAmB,CAACI,GAAG,CAACD,KAAK,CAACE,IAAuC,CAAC;AAExE,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,E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,EAAE,UAAU;IACpB0D,GAAG,EAAEjC,OAAO,EAAEiC,GAAG,IAAI,CAAC;IACtBC,IAAI,EAAElC,OAAO,EAAEkC,IAAI,IAAI,CAAC;IACxBE,KAAK,EAAEpC,OAAO,EAAEoC,KAAK,IAAI,CAAC;IAC1BD,MAAM,EAAEnC,OAAO,EAAEmC,MAAM,IAAI;EAC7B,CAAC;EAED,MAAMqB,QAAuB,GAAG;IAC9B7F,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV,CAAC;EAED,oBACE1B,KAAA,CAACR,IAAI;IAAC0D,KAAK,EAAEA,KAAM;IAAAD,QAAA,gBACjBnD,IAAA,CAACN,IAAI;MAAC0D,KAAK,EAAEmE,iBAAkB;MAAApE,QAAA,eAC7BjD,KAAA,CAACP,GAAG;QACF6D,KAAK,EAAEA,KAAM;QACb2D,aAAa,EAAEA,aAAc;QAC7BM,WAAW,EAAE/D,WAAY;QACzBC,OAAO,EAAEA,OAAQ;QACjBC,OAAO,EAAEA,OAAQ;QACjBsD,eAAe,EAAEA,eAAgB;QACjCQ,gBAAgB;QAChBC,IAAI,EAAE5D,YAAY,KAAK,KAAK,GAAG,CAAC,GAAGkB,SAAU;QAC7C7B,KAAK,EAAEoE,QAAS;QAAArE,QAAA,gBAEhBnD,IAAA,CAACiC,kBAAkB;UAACC,OAAO,EAAE+B;QAAoB,CAAE,CAAC,EACnDmD,WAAW;MAAA,CACT;IAAC,CACF,CAAC,EACNC,eAAe;EAAA,CACZ,CAAC;AAEX,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import { AdvancedMarker } from '@vis.gl/react-google-maps';
|
|
5
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
/**
|
|
7
|
-
* Converts point to % anchor for web.
|
|
8
|
-
* e.g. `0.5` to `-50%`
|
|
9
|
-
*/
|
|
10
5
|
const toWebAnchor = value => `-${value * 100}%`;
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const position = {
|
|
6
|
+
export function Marker({
|
|
7
|
+
coordinate,
|
|
8
|
+
title,
|
|
9
|
+
anchor,
|
|
10
|
+
zIndex,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
13
|
+
return /*#__PURE__*/_jsx(AdvancedMarker, {
|
|
14
|
+
position: {
|
|
21
15
|
lat: coordinate.latitude,
|
|
22
16
|
lng: coordinate.longitude
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
children: children
|
|
31
|
-
});
|
|
32
|
-
}
|
|
17
|
+
},
|
|
18
|
+
title: title,
|
|
19
|
+
zIndex: zIndex,
|
|
20
|
+
anchorLeft: anchor ? toWebAnchor(anchor.x) : undefined,
|
|
21
|
+
anchorTop: anchor ? toWebAnchor(anchor.y) : undefined,
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
33
24
|
}
|
|
34
25
|
//# sourceMappingURL=Marker.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["AdvancedMarker","jsx","_jsx","toWebAnchor","value","Marker","coordinate","title","anchor","zIndex","children","position","lat","latitude","lng","longitude","anchorLeft","x","undefined","anchorTop","y"],"sourceRoot":"../../../src","sources":["components/Marker.web.tsx"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,2BAA2B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG3D,MAAMC,WAAW,GAAIC,KAAa,IAAK,IAAIA,KAAK,GAAG,GAAG,GAAG;AAEzD,OAAO,SAASC,MAAMA,CAAC;EACrBC,UAAU;EACVC,KAAK;EACLC,MAAM;EACNC,MAAM;EACNC;AACW,CAAC,EAAE;EACd,oBACER,IAAA,CAACF,cAAc;IACbW,QAAQ,EAAE;MAAEC,GAAG,EAAEN,UAAU,CAACO,QAAQ;MAAEC,GAAG,EAAER,UAAU,CAACS;IAAU,CAAE;IAClER,KAAK,EAAEA,KAAM;IACbE,MAAM,EAAEA,MAAO;IACfO,UAAU,EAAER,MAAM,GAAGL,WAAW,CAACK,MAAM,CAACS,CAAC,CAAC,GAAGC,SAAU;IACvDC,SAAS,EAAEX,MAAM,GAAGL,WAAW,CAACK,MAAM,CAACY,CAAC,CAAC,GAAGF,SAAU;IAAAR,QAAA,EAErDA;EAAQ,CACK,CAAC;AAErB","ignoreList":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { useMap } from '@vis.gl/react-google-maps';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
5
|
const ANIMATION_DURATION = 1500;
|
|
7
6
|
function interpolateColor(color1, color2, t) {
|
|
8
7
|
const hex = c => parseInt(c, 16);
|
|
@@ -26,7 +25,7 @@ function getGradientColor(colors, position) {
|
|
|
26
25
|
const t = scaledPos - index;
|
|
27
26
|
return interpolateColor(colors[index], colors[index + 1], t);
|
|
28
27
|
}
|
|
29
|
-
function
|
|
28
|
+
export function Polyline({
|
|
30
29
|
coordinates,
|
|
31
30
|
strokeColors,
|
|
32
31
|
strokeWidth = 1,
|
|
@@ -167,11 +166,4 @@ function PolylineImpl({
|
|
|
167
166
|
}, [coordinates, animated, hasGradient, updatePath, mapReady]);
|
|
168
167
|
return null;
|
|
169
168
|
}
|
|
170
|
-
export class Polyline extends Component {
|
|
171
|
-
render() {
|
|
172
|
-
return /*#__PURE__*/_jsx(PolylineImpl, {
|
|
173
|
-
...this.props
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
169
|
//# sourceMappingURL=Polyline.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useMemo","useRef","useState","useMap","ANIMATION_DURATION","interpolateColor","color1","color2","t","hex","c","parseInt","r1","slice","g1","b1","r2","g2","b2","r","Math","round","g","b","toString","padStart","getGradientColor","colors","position","length","scaledPos","index","floor","Polyline","coordinates","strokeColors","strokeWidth","animated","zIndex","resolvedZIndex","map","polylinesRef","animationRef","hasGradient","propsRef","mapReady","setMapReady","current","updatePath","path","currentMap","currentColors","currentStrokeWidth","currentHasGradient","currentZIndex","neededSegments","existing","i","segmentPath","color","segment","setPath","setOptions","strokeColor","push","google","maps","strokeWeight","strokeOpacity","setMap","polylines","cancelAnimationFrame","forEach","p","fullPath","lat","latitude","lng","longitude","totalPoints","cycleDuration","animate","time","progress","startIdx","endIdx","partialPath","startFloor","endFloor","frac","from","to","min","requestAnimationFrame"],"sourceRoot":"../../../src","sources":["components/Polyline.web.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACzE,SAASC,MAAM,QAAQ,2BAA2B;AAGlD,MAAMC,kBAAkB,GAAG,IAAI;AAE/B,SAASC,gBAAgBA,CAACC,MAAc,EAAEC,MAAc,EAAEC,CAAS,EAAU;EAC3E,MAAMC,GAAG,GAAIC,CAAS,IAAKC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC;EAC1C,MAAME,EAAE,GAAGH,GAAG,CAACH,MAAM,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAClC,MAAMC,EAAE,GAAGL,GAAG,CAACH,MAAM,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAClC,MAAME,EAAE,GAAGN,GAAG,CAACH,MAAM,CAACO,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAClC,MAAMG,EAAE,GAAGP,GAAG,C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C,EAAE,EACH;QACA6B,WAAW,CAACtB,IAAI,CAACU,QAAQ,CAACjB,CAAC,CAAE,CAAC;MAChC;;MAEA;MACA,IAAI+B,QAAQ,GAAGT,WAAW,GAAG,CAAC,EAAE;QAC9B,MAAMU,IAAI,GAAGJ,MAAM,GAAGG,QAAQ;QAC9B,MAAME,IAAI,GAAGhB,QAAQ,CAACc,QAAQ,CAAE;QAChC,MAAMG,EAAE,GAAGjB,QAAQ,CAACc,QAAQ,GAAG,CAAC,CAAE;QAClC,IAAIC,IAAI,GAAG,CAAC,EAAE;UACZH,WAAW,CAACtB,IAAI,CAAC;YACfW,GAAG,EAAEe,IAAI,CAACf,GAAG,GAAG,CAACgB,EAAE,CAAChB,GAAG,GAAGe,IAAI,CAACf,GAAG,IAAIc,IAAI;YAC1CZ,GAAG,EAAEa,IAAI,CAACb,GAAG,GAAG,CAACc,EAAE,CAACd,GAAG,GAAGa,IAAI,CAACb,GAAG,IAAIY;UACxC,CAAC,CAAC;QACJ;MACF;MAEAzC,UAAU,CAACsC,WAAW,CAAC;MACvB5C,YAAY,CAACK,OAAO,GAAG8C,qBAAqB,CAACZ,OAAO,CAAC;IACvD,CAAC;IAEDvC,YAAY,CAACK,OAAO,GAAG8C,qBAAqB,CAACZ,OAAO,CAAC;IAErD,OAAO,MAAMV,oBAAoB,CAAC7B,YAAY,CAACK,OAAO,CAAC;EACzD,CAAC,EAAE,CAACb,WAAW,EAAEG,QAAQ,EAAEM,WAAW,EAAEK,UAAU,EAAEH,QAAQ,CAAC,CAAC;EAE9D,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import type { Coordinate } from './types';
|
|
4
|
-
export declare class MapView extends Component<MapViewProps> implements MapViewRef {
|
|
5
|
-
static defaultProps: Partial<MapViewProps>;
|
|
6
|
-
private mapInstance;
|
|
7
|
-
private handleMapReady;
|
|
8
|
-
moveCamera(coordinate: Coordinate, options: MoveCameraOptions): void;
|
|
9
|
-
fitCoordinates(coordinates: Coordinate[], options?: FitCoordinatesOptions): void;
|
|
10
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
}
|
|
1
|
+
import type { MapViewProps, MapViewRef } from './MapView.types';
|
|
2
|
+
export declare const MapView: import("react").ForwardRefExoticComponent<MapViewProps & import("react").RefAttributes<MapViewRef>>;
|
|
12
3
|
//# sourceMappingURL=MapView.web.d.ts.map
|
|
@@ -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":"AAkBA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAIX,MAAM,iBAAiB,CAAC;AAyEzB,eAAO,MAAM,OAAO,qGAyLlB,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { MarkerProps } from './Marker';
|
|
3
|
-
export declare
|
|
4
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
}
|
|
2
|
+
export declare function Marker({ coordinate, title, anchor, zIndex, children, }: MarkerProps): import("react/jsx-runtime").JSX.Element;
|
|
6
3
|
//# sourceMappingURL=Marker.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Marker.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,wBAAgB,MAAM,CAAC,EACrB,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,GACT,EAAE,WAAW,2CAYb"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
1
|
import type { PolylineProps } from './Polyline';
|
|
3
|
-
export declare
|
|
4
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
}
|
|
2
|
+
export declare function Polyline({ coordinates, strokeColors, strokeWidth, animated, zIndex, }: PolylineProps): null;
|
|
6
3
|
//# sourceMappingURL=Polyline.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polyline.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Polyline.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Polyline.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Polyline.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkChD,wBAAgB,QAAQ,CAAC,EACvB,WAAW,EACX,YAAY,EACZ,WAAe,EACf,QAAQ,EACR,MAAM,GACP,EAAE,aAAa,QAsKf"}
|
package/package.json
CHANGED
package/src/MapView.web.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Children,
|
|
3
|
-
|
|
3
|
+
forwardRef,
|
|
4
4
|
isValidElement,
|
|
5
5
|
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
6
7
|
useRef,
|
|
7
8
|
useState,
|
|
8
9
|
type CSSProperties,
|
|
@@ -24,7 +25,6 @@ import type {
|
|
|
24
25
|
} from './MapView.types';
|
|
25
26
|
import type { Coordinate } from './types';
|
|
26
27
|
|
|
27
|
-
// Map-specific component types that render inside the Google Map
|
|
28
28
|
const MAP_COMPONENT_TYPES = new Set([Marker, Polyline]);
|
|
29
29
|
|
|
30
30
|
const isMapComponent = (child: ReactElement): boolean =>
|
|
@@ -49,17 +49,6 @@ const createSyntheticEvent = <T,>(nativeEvent: T): NativeSyntheticEvent<T> =>
|
|
|
49
49
|
type: '',
|
|
50
50
|
} as unknown as NativeSyntheticEvent<T>);
|
|
51
51
|
|
|
52
|
-
interface MapControllerProps {
|
|
53
|
-
onMapReady: (map: google.maps.Map) => void;
|
|
54
|
-
onCameraMove?: (event: NativeSyntheticEvent<CameraEventPayload>) => void;
|
|
55
|
-
onCameraIdle?: (event: NativeSyntheticEvent<CameraEventPayload>) => void;
|
|
56
|
-
onReady?: () => void;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface UserLocationMarkerProps {
|
|
60
|
-
enabled?: boolean;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
52
|
const userLocationDotStyle: CSSProperties = {
|
|
64
53
|
width: 16,
|
|
65
54
|
height: 16,
|
|
@@ -69,7 +58,7 @@ const userLocationDotStyle: CSSProperties = {
|
|
|
69
58
|
boxShadow: '0 1px 4px rgba(0,0,0,0.3)',
|
|
70
59
|
};
|
|
71
60
|
|
|
72
|
-
function UserLocationMarker({ enabled }:
|
|
61
|
+
function UserLocationMarker({ enabled }: { enabled?: boolean }) {
|
|
73
62
|
const [coordinate, setCoordinate] = useState<Coordinate | null>(null);
|
|
74
63
|
|
|
75
64
|
useEffect(() => {
|
|
@@ -106,24 +95,89 @@ function UserLocationMarker({ enabled }: UserLocationMarkerProps) {
|
|
|
106
95
|
);
|
|
107
96
|
}
|
|
108
97
|
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
99
|
+
props,
|
|
100
|
+
ref
|
|
101
|
+
) {
|
|
102
|
+
const {
|
|
103
|
+
mapId = 'DEMO_MAP_ID',
|
|
104
|
+
initialCoordinate,
|
|
105
|
+
initialZoom = 10,
|
|
106
|
+
minZoom,
|
|
107
|
+
maxZoom,
|
|
108
|
+
zoomEnabled = true,
|
|
109
|
+
scrollEnabled = true,
|
|
110
|
+
pitchEnabled = true,
|
|
111
|
+
padding,
|
|
112
|
+
userLocationEnabled,
|
|
113
|
+
onCameraMove,
|
|
114
|
+
onCameraIdle,
|
|
115
|
+
onReady,
|
|
116
|
+
children,
|
|
117
|
+
style,
|
|
118
|
+
} = props;
|
|
119
|
+
|
|
115
120
|
const map = useMap();
|
|
116
121
|
const readyFired = useRef(false);
|
|
117
122
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
useImperativeHandle(
|
|
124
|
+
ref,
|
|
125
|
+
() => ({
|
|
126
|
+
moveCamera(coordinate: Coordinate, options: MoveCameraOptions) {
|
|
127
|
+
if (!map) return;
|
|
128
|
+
|
|
129
|
+
const { zoom, duration = -1 } = options;
|
|
130
|
+
const center = { lat: coordinate.latitude, lng: coordinate.longitude };
|
|
131
|
+
|
|
132
|
+
if (duration === 0) {
|
|
133
|
+
map.moveCamera({ center, zoom });
|
|
134
|
+
} else {
|
|
135
|
+
const currentZoom = map.getZoom();
|
|
136
|
+
const zoomChanged = zoom !== undefined && zoom !== currentZoom;
|
|
137
|
+
|
|
138
|
+
if (zoomChanged) {
|
|
139
|
+
map.setZoom(zoom);
|
|
140
|
+
}
|
|
141
|
+
map.panTo(center);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
fitCoordinates(
|
|
146
|
+
coordinates: Coordinate[],
|
|
147
|
+
options?: FitCoordinatesOptions
|
|
148
|
+
) {
|
|
149
|
+
const first = coordinates[0];
|
|
150
|
+
if (!map || !first) return;
|
|
151
|
+
|
|
152
|
+
const { padding: fitPadding, duration = -1 } = options ?? {};
|
|
153
|
+
|
|
154
|
+
if (coordinates.length === 1) {
|
|
155
|
+
this.moveCamera(first, { zoom: initialZoom, duration });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const bounds = new google.maps.LatLngBounds();
|
|
160
|
+
coordinates.forEach((coord) => {
|
|
161
|
+
bounds.extend({ lat: coord.latitude, lng: coord.longitude });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
map.fitBounds(bounds, {
|
|
165
|
+
top: fitPadding?.top ?? 0,
|
|
166
|
+
left: fitPadding?.left ?? 0,
|
|
167
|
+
bottom: fitPadding?.bottom ?? 0,
|
|
168
|
+
right: fitPadding?.right ?? 0,
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
}),
|
|
172
|
+
[map, initialZoom]
|
|
173
|
+
);
|
|
121
174
|
|
|
122
|
-
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
if (map && !readyFired.current) {
|
|
123
177
|
readyFired.current = true;
|
|
124
178
|
onReady?.();
|
|
125
179
|
}
|
|
126
|
-
}, [map,
|
|
180
|
+
}, [map, onReady]);
|
|
127
181
|
|
|
128
182
|
useEffect(() => {
|
|
129
183
|
if (!map) return;
|
|
@@ -141,9 +195,11 @@ function MapController({
|
|
|
141
195
|
};
|
|
142
196
|
|
|
143
197
|
let isDragging = false;
|
|
198
|
+
let wasGesture = false;
|
|
144
199
|
|
|
145
200
|
const dragStartListener = map.addListener('dragstart', () => {
|
|
146
201
|
isDragging = true;
|
|
202
|
+
wasGesture = true;
|
|
147
203
|
});
|
|
148
204
|
|
|
149
205
|
const dragEndListener = map.addListener('dragend', () => {
|
|
@@ -155,7 +211,8 @@ function MapController({
|
|
|
155
211
|
});
|
|
156
212
|
|
|
157
213
|
const idleListener = map.addListener('idle', () => {
|
|
158
|
-
onCameraIdle?.(createSyntheticEvent(createPayload(
|
|
214
|
+
onCameraIdle?.(createSyntheticEvent(createPayload(wasGesture)));
|
|
215
|
+
wasGesture = false;
|
|
159
216
|
});
|
|
160
217
|
|
|
161
218
|
return () => {
|
|
@@ -166,154 +223,61 @@ function MapController({
|
|
|
166
223
|
};
|
|
167
224
|
}, [map, onCameraMove, onCameraIdle]);
|
|
168
225
|
|
|
169
|
-
|
|
170
|
-
|
|
226
|
+
const gestureHandling =
|
|
227
|
+
scrollEnabled === false && zoomEnabled === false
|
|
228
|
+
? 'none'
|
|
229
|
+
: scrollEnabled === false
|
|
230
|
+
? 'none'
|
|
231
|
+
: 'auto';
|
|
171
232
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
mapId: 'DEMO_MAP_ID',
|
|
176
|
-
initialZoom: 10,
|
|
177
|
-
zoomEnabled: true,
|
|
178
|
-
scrollEnabled: true,
|
|
179
|
-
rotateEnabled: true,
|
|
180
|
-
pitchEnabled: true,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
private mapInstance: google.maps.Map | null = null;
|
|
233
|
+
const defaultCenter = initialCoordinate
|
|
234
|
+
? { lat: initialCoordinate.latitude, lng: initialCoordinate.longitude }
|
|
235
|
+
: undefined;
|
|
184
236
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
moveCamera(coordinate: Coordinate, options: MoveCameraOptions) {
|
|
190
|
-
const map = this.mapInstance;
|
|
191
|
-
if (!map) return;
|
|
237
|
+
const mapChildren: ReactNode[] = [];
|
|
238
|
+
const overlayChildren: ReactNode[] = [];
|
|
192
239
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
map.moveCamera({ center, zoom });
|
|
240
|
+
Children.forEach(children, (child) => {
|
|
241
|
+
if (!isValidElement(child)) return;
|
|
242
|
+
if (isMapComponent(child)) {
|
|
243
|
+
mapChildren.push(child);
|
|
198
244
|
} else {
|
|
199
|
-
|
|
200
|
-
const zoomChanged = zoom !== undefined && zoom !== currentZoom;
|
|
201
|
-
|
|
202
|
-
if (zoomChanged) {
|
|
203
|
-
map.setZoom(zoom);
|
|
204
|
-
}
|
|
205
|
-
map.panTo(center);
|
|
245
|
+
overlayChildren.push(child);
|
|
206
246
|
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (coordinates.length === 1) {
|
|
217
|
-
const zoom = this.props.initialZoom ?? 10;
|
|
218
|
-
this.moveCamera(first, { zoom, duration });
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const bounds = new google.maps.LatLngBounds();
|
|
223
|
-
coordinates.forEach((coord) => {
|
|
224
|
-
bounds.extend({ lat: coord.latitude, lng: coord.longitude });
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
map.fitBounds(bounds, {
|
|
228
|
-
top: padding?.top ?? 0,
|
|
229
|
-
left: padding?.left ?? 0,
|
|
230
|
-
bottom: padding?.bottom ?? 0,
|
|
231
|
-
right: padding?.right ?? 0,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
render() {
|
|
236
|
-
const {
|
|
237
|
-
mapId,
|
|
238
|
-
initialCoordinate,
|
|
239
|
-
initialZoom,
|
|
240
|
-
minZoom,
|
|
241
|
-
maxZoom,
|
|
242
|
-
zoomEnabled,
|
|
243
|
-
scrollEnabled,
|
|
244
|
-
pitchEnabled,
|
|
245
|
-
padding,
|
|
246
|
-
userLocationEnabled,
|
|
247
|
-
onCameraMove,
|
|
248
|
-
onCameraIdle,
|
|
249
|
-
onReady,
|
|
250
|
-
children,
|
|
251
|
-
style,
|
|
252
|
-
} = this.props;
|
|
253
|
-
|
|
254
|
-
const gestureHandling =
|
|
255
|
-
scrollEnabled === false && zoomEnabled === false
|
|
256
|
-
? 'none'
|
|
257
|
-
: scrollEnabled === false
|
|
258
|
-
? 'none'
|
|
259
|
-
: 'auto';
|
|
260
|
-
|
|
261
|
-
const defaultCenter = initialCoordinate
|
|
262
|
-
? { lat: initialCoordinate.latitude, lng: initialCoordinate.longitude }
|
|
263
|
-
: undefined;
|
|
264
|
-
|
|
265
|
-
// Separate map children (Marker, Polyline) from overlay children (regular Views)
|
|
266
|
-
const mapChildren: ReactNode[] = [];
|
|
267
|
-
const overlayChildren: ReactNode[] = [];
|
|
268
|
-
|
|
269
|
-
Children.forEach(children, (child) => {
|
|
270
|
-
if (!isValidElement(child)) return;
|
|
271
|
-
if (isMapComponent(child)) {
|
|
272
|
-
mapChildren.push(child);
|
|
273
|
-
} else {
|
|
274
|
-
overlayChildren.push(child);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
const mapContainerStyle: ViewStyle = {
|
|
279
|
-
position: 'absolute',
|
|
280
|
-
top: padding?.top ?? 0,
|
|
281
|
-
left: padding?.left ?? 0,
|
|
282
|
-
right: padding?.right ?? 0,
|
|
283
|
-
bottom: padding?.bottom ?? 0,
|
|
284
|
-
};
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const mapContainerStyle: ViewStyle = {
|
|
250
|
+
position: 'absolute',
|
|
251
|
+
top: padding?.top ?? 0,
|
|
252
|
+
left: padding?.left ?? 0,
|
|
253
|
+
right: padding?.right ?? 0,
|
|
254
|
+
bottom: padding?.bottom ?? 0,
|
|
255
|
+
};
|
|
285
256
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
257
|
+
const mapStyle: CSSProperties = {
|
|
258
|
+
width: '100%',
|
|
259
|
+
height: '100%',
|
|
260
|
+
};
|
|
290
261
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
onCameraIdle={onCameraIdle}
|
|
309
|
-
onReady={onReady}
|
|
310
|
-
/>
|
|
311
|
-
<UserLocationMarker enabled={userLocationEnabled} />
|
|
312
|
-
{mapChildren}
|
|
313
|
-
</Map>
|
|
314
|
-
</View>
|
|
315
|
-
{overlayChildren}
|
|
262
|
+
return (
|
|
263
|
+
<View style={style}>
|
|
264
|
+
<View style={mapContainerStyle}>
|
|
265
|
+
<Map
|
|
266
|
+
mapId={mapId}
|
|
267
|
+
defaultCenter={defaultCenter}
|
|
268
|
+
defaultZoom={initialZoom}
|
|
269
|
+
minZoom={minZoom}
|
|
270
|
+
maxZoom={maxZoom}
|
|
271
|
+
gestureHandling={gestureHandling}
|
|
272
|
+
disableDefaultUI
|
|
273
|
+
tilt={pitchEnabled === false ? 0 : undefined}
|
|
274
|
+
style={mapStyle}
|
|
275
|
+
>
|
|
276
|
+
<UserLocationMarker enabled={userLocationEnabled} />
|
|
277
|
+
{mapChildren}
|
|
278
|
+
</Map>
|
|
316
279
|
</View>
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
280
|
+
{overlayChildren}
|
|
281
|
+
</View>
|
|
282
|
+
);
|
|
283
|
+
});
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { AdvancedMarker } from '@vis.gl/react-google-maps';
|
|
3
2
|
import type { MarkerProps } from './Marker';
|
|
4
3
|
|
|
5
|
-
/**
|
|
6
|
-
* Converts point to % anchor for web.
|
|
7
|
-
* e.g. `0.5` to `-50%`
|
|
8
|
-
*/
|
|
9
4
|
const toWebAnchor = (value: number) => `-${value * 100}%`;
|
|
10
5
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</AdvancedMarker>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
6
|
+
export function Marker({
|
|
7
|
+
coordinate,
|
|
8
|
+
title,
|
|
9
|
+
anchor,
|
|
10
|
+
zIndex,
|
|
11
|
+
children,
|
|
12
|
+
}: MarkerProps) {
|
|
13
|
+
return (
|
|
14
|
+
<AdvancedMarker
|
|
15
|
+
position={{ lat: coordinate.latitude, lng: coordinate.longitude }}
|
|
16
|
+
title={title}
|
|
17
|
+
zIndex={zIndex}
|
|
18
|
+
anchorLeft={anchor ? toWebAnchor(anchor.x) : undefined}
|
|
19
|
+
anchorTop={anchor ? toWebAnchor(anchor.y) : undefined}
|
|
20
|
+
>
|
|
21
|
+
{children}
|
|
22
|
+
</AdvancedMarker>
|
|
23
|
+
);
|
|
32
24
|
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
useCallback,
|
|
4
|
-
useEffect,
|
|
5
|
-
useMemo,
|
|
6
|
-
useRef,
|
|
7
|
-
useState,
|
|
8
|
-
} from 'react';
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
2
|
import { useMap } from '@vis.gl/react-google-maps';
|
|
10
3
|
import type { PolylineProps } from './Polyline';
|
|
11
4
|
|
|
@@ -41,7 +34,7 @@ function getGradientColor(colors: string[], position: number): string {
|
|
|
41
34
|
return interpolateColor(colors[index]!, colors[index + 1]!, t);
|
|
42
35
|
}
|
|
43
36
|
|
|
44
|
-
function
|
|
37
|
+
export function Polyline({
|
|
45
38
|
coordinates,
|
|
46
39
|
strokeColors,
|
|
47
40
|
strokeWidth = 1,
|
|
@@ -214,9 +207,3 @@ function PolylineImpl({
|
|
|
214
207
|
|
|
215
208
|
return null;
|
|
216
209
|
}
|
|
217
|
-
|
|
218
|
-
export class Polyline extends Component<PolylineProps> {
|
|
219
|
-
render() {
|
|
220
|
-
return <PolylineImpl {...this.props} />;
|
|
221
|
-
}
|
|
222
|
-
}
|