Leaflet自定義svg圖標--divIcon

data() {
    return {
            fillColor: "#1afa29",
            placeName: "name",
           }
       }

computed: {
    customTowerIcon() {
      let svgContent = `<svg class="icon" width="30" height="30" fill="${this.fillColor}" aria-hidden="true"><use xlink:href="#icon-tubiao_jingdongtieta" /></svg>`;
      // let divContent = `<p style="color:white">${this.placeName}</p>`;
      let customColorIcon = L.divIcon({
        iconSize: [30, 30],
        className: "custom-color-icon",
        html: svgContent
      });
      return customColorIcon;
    }
  },

//使用
let marker = L.marker(latlngs, {
          icon: this.customTowerIcon,
          place: item.place
        });

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章