【发布时间】:2021-04-25 15:08:24
【问题描述】:
我尝试了几个示例,但结果是损坏的图像或默认图标
<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-marker 中使用L.icon(),但它会产生损坏的图像
模板
<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
});
}
【问题讨论】:
-
不,它不工作
标签: vue.js vuejs2 leaflet vue2leaflet