按理说定点清除散点图,只清除散点图.但是运行清除以后只清了打印的第一个
InitSplashes(val) {
let _this=this
var InfoWindow = null;
InfoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -30) }); // 这里控制信息框的位置
// var lnglats = this.markers //this.markers是后台返回的数据在data中定义的
for (var i = 0; i < this.lnglats.length; i++) {
var marker = new AMap.Marker({
position: [this.lnglats[i].lng, this.lnglats[i].lat],
map: this.weXinAmapMap,
zoom: 7,
});
let content= this.ScatterChartTitle + this.lnglats[i].count + this.ScatterChartTitleTail //设置文本标注内容
marker.setTitle(content)
//鼠标时悬浮触发
marker.on("mouseover", function (e) {
_this.weXinAmapMap.remove(marker)//卸载散点图,按理说是全清了但是,只清了一个
// //散点图 头部标题 这里也是,按理说应该是全部显示标题,但是只显示了一个
// marker.setLabel({
// direction: 'top',
// offset: new AMap.Pixel(10, 0), //设置文本标注偏移量
// content: content
// });
});
marker.emit("click", { target: marker });
}
this.weXinAmapMap.setFitView();
},
我个人感觉应该是循环渲染的锅,每次创建一个新的,每个对象都不一样,所以只能卸载最后一个(不知道现在卸载的是第几个).难不成在生成新的同时要都存起来,回头卸载的时候循环出来删??这也太那什么了吧,
有没有一次性能清除地图上的全部散点图和热力图的办法!头秃了
单独清除散点图和单独清除热力图的办法