接这篇文章:https://www.jianshu.com/p/03ad118cc52c
调用文档:https://leafletjs.com/reference-1.7.1.html#marker
var iconMarker = new L.Icon({
iconUrl:
"https://cdn.jsdelivr.net/npm/leaflet@1.7.1/dist/images/marker-icon.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
// x,y为经纬度坐标点 x:lng y:lat
L.marker([y, x], {
icon: iconMarker,
}).addTo(map);