参考之前博客进行创建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