contextmenu, manchmal geht manchmal nicht, Timing Problem
This commit is contained in:
29
utils/polylines/contextMenu.js
Normal file
29
utils/polylines/contextMenu.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// /utils/polylines/contextMenu.js
|
||||
export function closePolylineSelectionAndContextMenu(map) {
|
||||
try {
|
||||
if (window.selectedPolyline) {
|
||||
window.selectedPolyline.setStyle({ weight: 3 });
|
||||
window.selectedPolyline = null;
|
||||
}
|
||||
|
||||
if (map?.contextmenu?.hide) {
|
||||
map.contextmenu.hide();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Schließen des Kontextmenüs:", error);
|
||||
}
|
||||
|
||||
localStorage.removeItem("contextMenuCountdown");
|
||||
localStorage.removeItem("contextMenuExpired");
|
||||
}
|
||||
|
||||
export function monitorContextMenu(map) {
|
||||
function checkAndClose() {
|
||||
if (localStorage.getItem("contextMenuExpired") === "true") {
|
||||
closePolylineSelectionAndContextMenu(map);
|
||||
localStorage.removeItem("contextMenuExpired");
|
||||
}
|
||||
setTimeout(checkAndClose, 1000);
|
||||
}
|
||||
checkAndClose();
|
||||
}
|
||||
Reference in New Issue
Block a user