前提:百度地图上加了鼠标滚动缩放功能,上面是筛选条件的切换,实际操作中,很容易缩放或者移动地图,导致点位没有出现在盒子的中间,体验感不好
getMapPointer() {
this.Informationwindowdata = []
if (this.data) {
this.data.forEach(item => {
let data = {
lng: item.lang,
lat: item.lat
}
this.Informationwindowdata.push(data)
})
this.map.setCenter(
new this.BMap.Point(this.Informationwindowdata[0].lng, this.Informationwindowdata[0].lat)
)
this.center.lng = this.Informationwindowdata[0].lng
this.center.lat = this.Informationwindowdata[0].lat
this.zoom = 15
}
},
html:
<baidu-map
style="width: 100%; height: 100%"
:center="center"
:scroll-wheel-zoom="true"
class="map"
:zoom="zoom"
@ready="handler"
>
<div v-for="obj in Informationwindowdata">
<bm-marker :position="{ lng: obj.lng, lat: obj.lat }" >
</bm-marker>
</div>
</baidu-map>