change map marker icon

This commit is contained in:
MaysWind
2023-05-15 23:31:53 +08:00
parent a55256ad82
commit 4e561dc764
4 changed files with 12 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

+12 -1
View File
@@ -95,7 +95,18 @@ export default {
if (centerChanged && this.zoomLevel > 1) {
if (!this.marker) {
this.marker = this.$map.leaflet.marker(this.initCenter).addTo(this.leaflet);
const markerIcon = this.$map.leaflet.icon({
iconUrl: 'img/map-marker-icon.png',
iconRetinaUrl: 'img/map-marker-icon-2x.png',
iconSize: [25, 32],
iconAnchor: [12, 32],
shadowUrl: 'img/map-marker-shadow.png',
shadowSize: [41, 32]
});
this.marker = this.$map.leaflet.marker(this.initCenter, {
icon: markerIcon
});
this.marker.addTo(this.leaflet);
} else {
this.marker.setLatLng(this.initCenter);
}