data() {
return {
markericon: []
};
},
mounted(){
this.initmap();//地图实例,不是重点,代码不贴了
},
for(...){
var myIcon = L.divIcon({
html: `<div class="title" >${
item.siteName
}</div><img style="width:30px;height:30px" src="${require("../../assets/radar.png")}"/>`,
className: "my-div-icon",
//动态计算icon的显示宽度
iconSize: that.$L.point(item.siteName.length * 14, 40)
});
let m = that.$L.marker(
coordtransform
.wgs84togcj02(item.longitude, item.latitude)
.reverse(),
{
title: item.siteName,
icon: myIcon
}
);
that.markericon.push(m);
}
that.layerGroup = L.layerGroup(that.markericon);
that.map.addLayer(that.layerGroup);
03-12
911

11-22
4807
