|
|
@@ -21,11 +21,10 @@
|
|
|
}"
|
|
|
:fullscreenControl="false"
|
|
|
style="width: 100vw; height: 100vh"
|
|
|
- @click="handleMapClick"
|
|
|
v-loading="loadingRef"
|
|
|
:loading-tip="t('common.loadingText')"
|
|
|
>
|
|
|
- <MarkerCluster>
|
|
|
+ <MarkerCluster v-if="locations.length > 0">
|
|
|
<template v-for="(location, i) in locations" :key="i">
|
|
|
<CustomMarker
|
|
|
v-if="location.isPro"
|
|
|
@@ -230,8 +229,8 @@
|
|
|
if (ready && lo.value.length > 0) {
|
|
|
// debugger;
|
|
|
try {
|
|
|
- console.error('没开- mapFitBounds');
|
|
|
- // mapFitBounds(mapRef, locations.value);
|
|
|
+ // console.error('没开- mapFitBounds');
|
|
|
+ mapFitBounds(mapRef, locations.value);
|
|
|
} catch (error) {}
|
|
|
}
|
|
|
},
|
|
|
@@ -275,22 +274,22 @@
|
|
|
location.reload();
|
|
|
}
|
|
|
|
|
|
- // function mapFitBounds(mapRef, markers) {
|
|
|
- // let bounds;
|
|
|
- // const api = mapRef.value.api;
|
|
|
- // const map = mapRef.value.map;
|
|
|
+ function mapFitBounds(mapRef, markers) {
|
|
|
+ let bounds;
|
|
|
+ const api = mapRef.value.api;
|
|
|
+ const map = mapRef.value.map;
|
|
|
|
|
|
- // bounds = new api.LatLngBounds();
|
|
|
- // for (let i = 0; i < markers.length; i++) {
|
|
|
- // bounds.extend(markers[i]);
|
|
|
- // }
|
|
|
- // map.fitBounds(bounds);
|
|
|
- // map.panToBounds(bounds);
|
|
|
- // }
|
|
|
- const handleMapClick = (event) => {
|
|
|
- const { lat, lng } = event.latLng;
|
|
|
- console.log('event', `{ lat: ${lat()}, lng: ${lng()}}`);
|
|
|
- };
|
|
|
+ bounds = new api.LatLngBounds();
|
|
|
+ for (let i = 0; i < markers.length; i++) {
|
|
|
+ bounds.extend(markers[i]);
|
|
|
+ }
|
|
|
+ map.fitBounds(bounds);
|
|
|
+ map.panToBounds(bounds);
|
|
|
+ }
|
|
|
+ // const handleMapClick = (event) => {
|
|
|
+ // const { lat, lng } = event.latLng;
|
|
|
+ // console.log('event', `{ lat: ${lat()}, lng: ${lng()}}`);
|
|
|
+ // };
|
|
|
|
|
|
const handleMarkerClick = (data) => {
|
|
|
// const { lat, lng } = event.latLng;
|