Google maps vue谷歌地图-仅为'fitBounds'调用设置最大缩放级别
第一次使用vue谷歌地图。每当我向地图添加标记,并执行Google maps vue谷歌地图-仅为'fitBounds'调用设置最大缩放级别,google-maps,vue.js,vuejs2,Google Maps,Vue.js,Vuejs2,第一次使用vue谷歌地图。每当我向地图添加标记,并执行fitBounds 我的代码: setMapBounds(markers = null) { if (!markers) { markers = this.mapMarkers } //set bounds of the map this.$refs.gmap.$mapPromise.then((m
fitBounds
我的代码:
setMapBounds(markers = null) {
if (!markers) {
markers = this.mapMarkers
}
//set bounds of the map
this.$refs.gmap.$mapPromise.then((map) => {
if (markers.length) {
this.initialZoom = 6;
const bounds = new google.maps.LatLngBounds();
for (let m of markers) {
bounds.extend(this.getCreatorLocation(m));
}
map.fitBounds(bounds);
} else {
this.initialZoom = 5;
}
});
},
如何在fitBounds
map.fitBounds(bounds);
var listener = google.maps.event.addListener(map, "idle", function() {
if (map.getZoom() > 16) map.setZoom(16);
google.maps.event.removeListener(listener);
});