drawMarker(arr) {
if (this.myGroup) {
this.myGroup.clearLayers();
this.myGroup = null;
}
const layers = [];
for (const item of arr) {
const myIcon = L.divIcon({
iconSize: [30 * this.rem, 30 * this.rem],
iconAnchor: [15 * this.rem, 15 * this.rem],
className: `map-icon-class`,
// html: `<div><span class=status_${item.status}></span><p class="letter">${item.name}</p ></div>`,
html: `<span class="status_${item.status || 1} id_${item.id}"></span>`
});
if (item.lttd && item.lgtd) {
const marker = L.marker([item.lttd, item.lgtd], {
icon: myIcon
});
marker.on(`click`, () => {
this.showSluiceInfo = item;
this.SET_BIG_STATIONLIST_INFO({ item });
this.showDescDialog();
});
layers.push(marker);
}
}
this.myGroup = L.layerGroup(layers);
this.map.addLayer(this.myGroup);
// L.layerGroup(layers).setZIndex(98).addTo(this.map);
},
2021-08-05 leaflet 地图上画点标注
最新推荐文章于 2024-08-31 16:38:59 发布