fix(devices): Duplikate im Kontextmenü "Station öffnen" behoben

- Mehrfaches Hinzufügen bei jedem Rechtsklick unterbunden
- Kontextmenü-Initialisierung mit contextMenuCreated abgesichert
- Datei: createAndSetDevices.js
This commit is contained in:
ISA
2025-05-27 14:45:58 +02:00
parent a19bf96843
commit 40afadb178
4 changed files with 46 additions and 7 deletions

View File

@@ -118,10 +118,31 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste
}
};
let contextMenuCreated = false;
marker.on("contextmenu", (event) => {
event.originalEvent?.preventDefault();
marker.openPopup();
addDeviceContextMenu(map, marker);
if (!contextMenuCreated) {
contextMenuCreated = true;
marker.bindContextMenu({
contextmenu: true,
contextmenuWidth: 160,
contextmenuItems: [
{ separator: true },
{
text: "Station öffnen (Tab)",
icon: "/img/screen_new.png",
callback: () => {
const link = `${window.location.origin}${basePath}/cpl.aspx?ver=35&kue=24&id=${station.IdLD}`;
window.open(link, "_blank");
},
},
],
});
}
});
map.on("click", () => {