当前位置: 代码迷 >> 综合 >> vue+leaflet 删除地图全部markers
  详细解决方案

vue+leaflet 删除地图全部markers

热度:29   发布时间:2023-10-14 03:46:56.0
 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);