我尝试了几个示例,但结果是图像损坏或默认图标
<l-marker
v-for="marker in getFilteredVehicles"
:lat-lng="marker.latLng"
:key="marker.rtoNo"
@click="openVehicleStatus(marker)"
>
<l-icon
:icon-size="[20,40]"
:icon-anchor="[22, 94]"
icon-url="src/assets/icons/map-icons/d-green-car.png" >
</l-icon>
</l-marker>
即使我尝试过使用L.icon()
inl-marker
但它产生了损坏的图像
模板
<l-marker
v-for="marker in getVehicles"
:lat-lng="marker.latLng"
:key="marker.rtoNo"
:icon="getIcon()"
@click="openVehicleStatus(marker)"
>
脚本
getIcon() {
return L.icon({
iconUrl: "src/assets/icons/map-icons/d-green-car.png",
shadowUrl: "src/assets/icons/map-icons/d-green-car.png",
iconSize: [38, 95], // size of the icon
shadowSize: [50, 64], // size of the shadow
iconAnchor: [22, 94], // point of the icon which will correspond to marker's location
shadowAnchor: [4, 62], // the same for the shadow
popupAnchor: [-3, -76] // point from which the po
});
}