删除makerb标注的添加和删除
var myIcon = new BMapGL.Icon(require('@/assets/map/position.png'), new BMapGL.Size(105, 95));
var adds = [
new BMapGL.Point(115.799145,28.628876),
new BMapGL.Point(115.805475,28.614241),
new BMapGL.Point(115.80056 ,28.60097),
new BMapGL.Point(115.81203 ,28.59490),
new BMapGL.Point(115.792634,28.583925),
new BMapGL.Point(115.810247,28.588456),
new BMapGL.Point(115.78419 ,28.57704),
new BMapGL.Point( 115.82234 ,28.60700),
];
for(var i = 0; i<adds.length; i++){
var marker = new BMapGL.Marker(adds[i],{icon: myIcon});
var label = new BMapGL.Label(this.mapData[i].name, {offset:new BMapGL.Size(-32,-40)})
label.setStyle({
color: '#fff',
fontSize: '12px',
background: 0,
border: 0
})
marker.setLabel(label);
this.map.addOverlay(marker);
marker.customData = {
id: i
}
marker.addEventListener('click', function (e) {
let id = e.target.customData.id
console.log('点击图标')
console.log(id)
that.$router.push('/home')
sessionStorage.setItem('mapIndex', id)
});
}
marker.setPosition(point)
marker.id = data[0].id
const allOverlays = map.getOverlays()
for (let i = 0; i < allOverlays.length; i++) {
if (allOverlays[i].id == data[0].id) {
map.removeOverlay(allOverlays[i])
}
}