@cashub/ui 0.25.1 → 0.25.2
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/map/GoogleMap.js +34 -23
- package/package.json +1 -1
package/map/GoogleMap.js
CHANGED
|
@@ -159,32 +159,39 @@ const Map = _ref2 => {
|
|
|
159
159
|
if (map) {
|
|
160
160
|
map.setOptions(options);
|
|
161
161
|
window.google.maps.event.addListenerOnce(map, 'idle', () => {
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// locate to the center of all coordinates on first load
|
|
167
|
-
const latLngBounds = new window.google.maps.LatLngBounds();
|
|
168
|
-
bounds.forEach(bound => {
|
|
169
|
-
latLngBounds.extend(bound);
|
|
162
|
+
if (geoFence) {
|
|
163
|
+
map.setCenter({
|
|
164
|
+
lat: geoFenceOptions.latitude,
|
|
165
|
+
lng: geoFenceOptions.longitude
|
|
170
166
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
} else {
|
|
168
|
+
if (bounds.length === 1) {
|
|
169
|
+
// there is only one location, locate it
|
|
170
|
+
map.setCenter(bounds[0]);
|
|
171
|
+
} else if (locations.length > 0) {
|
|
172
|
+
// locate to the center of all coordinates on first load
|
|
173
|
+
const latLngBounds = new window.google.maps.LatLngBounds();
|
|
174
|
+
bounds.forEach(bound => {
|
|
175
|
+
latLngBounds.extend(bound);
|
|
176
|
+
});
|
|
177
|
+
map.fitBounds(latLngBounds);
|
|
178
|
+
const found = locations.find(location => {
|
|
179
|
+
return latLngBounds.contains({
|
|
180
|
+
lat: location.latitude,
|
|
181
|
+
lng: location.longitude
|
|
182
|
+
});
|
|
176
183
|
});
|
|
177
|
-
});
|
|
178
184
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
185
|
+
// if center no contain any marker then locate to first location
|
|
186
|
+
if (!found) {
|
|
187
|
+
map.setCenter(bounds[0]);
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
map.setCenter({
|
|
191
|
+
lat: position && position.latitude || defaultPosition.latitude,
|
|
192
|
+
lng: position && position.longitude || defaultPosition.longitude
|
|
193
|
+
});
|
|
182
194
|
}
|
|
183
|
-
} else {
|
|
184
|
-
map.setCenter({
|
|
185
|
-
lat: position && position.latitude || defaultPosition.latitude,
|
|
186
|
-
lng: position && position.longitude || defaultPosition.longitude
|
|
187
|
-
});
|
|
188
195
|
}
|
|
189
196
|
});
|
|
190
197
|
return () => {
|
|
@@ -370,8 +377,12 @@ const Map = _ref2 => {
|
|
|
370
377
|
window.google.maps.event.clearListeners(circle, 'click');
|
|
371
378
|
window.google.maps.event.clearListeners(circle, 'radius_changed');
|
|
372
379
|
window.google.maps.event.clearListeners(circle, 'center_changed');
|
|
380
|
+
|
|
381
|
+
// remove reposition button if exist
|
|
373
382
|
const rightBottonControls = map.controls[google.maps.ControlPosition.RIGHT_BOTTOM];
|
|
374
|
-
rightBottonControls.
|
|
383
|
+
if (rightBottonControls.getAt(0)) {
|
|
384
|
+
rightBottonControls.removeAt(0);
|
|
385
|
+
}
|
|
375
386
|
};
|
|
376
387
|
}
|
|
377
388
|
}, [map, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude, geoFenceOptions.radius, geoFenceOptions.minRadius, geoFenceOptions.editable, geoFenceOptions.eventHandlers]);
|