[英]Can i modify the CSS of a marker icon on an event (make it bigger) with leaflet
我實際上是在Angular服務中使用傳單,我通過這種方法生成標記圖標:
private getIcon(geoJsonPoint) {
if (geoJsonPoint.properties.actif_id) {
const category = geoJsonPoint.properties.category.toUpperCase();
const prioritie = geoJsonPoint.properties.priority.toUpperCase();
const id = geoJsonPoint.properties.id;
console.log(geoJsonPoint);
const url = 'assets/images/' + category + '/' + prioritie + '.svg';
return L.icon({
iconUrl: url,
className: id,
iconSize: [58, 68],
iconAnchor: [29, 68],
popupAnchor: [0, -60]
});
所以在傳單事件(popupen)上,我想使我的圖標變大而無需設置新圖標,而僅需進行CSS修改。 傳單是允許這種事情還是已經有人做過?
謝謝!
我設法使用L.DomUtil和setTransform解決了這個問題,如果可以幫助任何人,我會在下面發布代碼。 我想我想在popupopen事件上轉換圖標。
private zoomIconOnPopupOpen(scale): void {
this.map.on('popupopen', (event1: any) => {
let marker = event1.popup._source;
if (marker._icon) {
const pos = L.DomUtil.getPosition(marker._icon);
L.DomUtil.setTransform(marker._icon, pos, scale);
}
});
this.map.on('popupclose', (event1: any) => {
let marker = event1.popup._source;
if (marker._icon) {
const pos = L.DomUtil.getPosition(marker._icon);
L.DomUtil.setTransform(marker._icon, pos, 1);
}
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.