This commit is contained in:
yanran200730
2022-07-04 09:21:01 +08:00
parent f8326726fd
commit c479b914d7
2 changed files with 21 additions and 3 deletions

View File

@@ -32,7 +32,8 @@
polygons: [],
labels: [],
businessName: '',
ops: {},
ops: {
},
markers: [],
isShow: false,
MarkerCluster: null,
@@ -154,7 +155,7 @@
}
}
this.config.latlng && map.setCenter(this.config.latlng)
// this.config.latlng && map.setCenter(this.config.latlng)
this.MarkerCluster = new TMap.MarkerCluster({
map, gridSize: 60,
@@ -167,6 +168,10 @@
})) || [],
zoomOnClick: true
})
this.setCenter(points.map(e => {
return new TMap.LatLng(e.lat, e.lng)
}))
let cls = []
this.MarkerCluster.on('cluster_changed', () => {
if (this.markers.length) {
@@ -226,6 +231,19 @@
}
}
})
},
setCenter (arr) {
var bounds = new TMap.LatLngBounds()
arr.forEach(function(item){
if (bounds.isEmpty() || !bounds.contains(item)){
bounds.extend(item)
}
})
this.map.fitBounds(bounds, {
padding: 100
})
}
}
}