參考之前博客進行創建leaflet地圖
添加圖標
customIcon = L.icon({iconUrl: `helicopter0.png`,//圖片路徑放在public中iconSize: [35, 35],iconAnchor: [15, 15],tooltipAnchor: [20, 0],});
let marker = L.marker([obj.lat, obj.lon], { icon: customIcon, rotationAngle: '偏轉角'}).addTo(this.myGroup);
修改圖標位置經緯度
let newIcon = L.icon({iconUrl: `helicopter0.png`,//圖片路徑放在public中iconSize: [35, 35],iconAnchor: [15, 15],tooltipAnchor: [20, 0],});
marker.setIcon(newIcon);//修改圖標
marker.setLatLng([經度, 維度])//修改圖標經緯度
//marker表示創建maker
從圖層組中刪除maker
this.myGroup.removeLayer(marker);
參考文檔鏈接: leaflet