效果:
需求:实现热力图和医院点图叠加显示
watch: {
selectMapKeys: { // 监听选中的checkbox是否发生变化
handler: function (val) {
if (this.earthquakeInfo.id) {
this.addLayers(val)
}
},
deep: true
},
earthquakeInfo: {
handler: function (val) { // 监听地震事件是否被切换
this.mapKeys = val.mapKeys
this.center = {
lng: val.longitude,
lat: val.latitude
}
this.dist = null
this.map.clearOverlays()
// 切换事件后,先清除影响场图层
this.heatMapLayer = null
this.getPlace(val.place) // 获取省市区
this.initMap(true, val.place, true)
},
deep: true
}
},
地图初始化:
if (!this.map) {
this.map = new BMapGL.Map('map')
this.map.enableScrollWheelZoom(true)
}
this.map.centerAndZoom(new BMapG