Got context menu working
This commit is contained in:
parent
4dfc0fdf84
commit
429663d80c
@ -375,11 +375,9 @@
|
|||||||
|
|
||||||
// Handle right-click context menu
|
// Handle right-click context menu
|
||||||
map.on('contextmenu', function(e) {
|
map.on('contextmenu', function(e) {
|
||||||
console.log('contextmenu event:', e);
|
|
||||||
e.originalEvent.preventDefault();
|
e.originalEvent.preventDefault();
|
||||||
const clientX = e.originalEvent.clientX || e.originalEvent.pageX;
|
const clientX = e.originalEvent.clientX || e.originalEvent.pageX;
|
||||||
const clientY = e.originalEvent.clientY || e.originalEvent.pageY;
|
const clientY = e.originalEvent.clientY || e.originalEvent.pageY;
|
||||||
console.log('Context menu coordinates:', clientX, clientY);
|
|
||||||
showContextMenu(clientX, clientY, e.latlng);
|
showContextMenu(clientX, clientY, e.latlng);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -422,11 +420,9 @@
|
|||||||
|
|
||||||
// Context menu functions
|
// Context menu functions
|
||||||
function showContextMenu(x, y, latlng) {
|
function showContextMenu(x, y, latlng) {
|
||||||
console.log('showContextMenu called with:', x, y, latlng);
|
|
||||||
hideContextMenu();
|
hideContextMenu();
|
||||||
const contextMenu = document.getElementById('contextMenu');
|
const contextMenu = document.getElementById('contextMenu');
|
||||||
contextMenuPosition = latlng;
|
contextMenuPosition = latlng;
|
||||||
console.log('contextMenuPosition set to:', contextMenuPosition);
|
|
||||||
|
|
||||||
contextMenu.style.display = 'block';
|
contextMenu.style.display = 'block';
|
||||||
contextMenu.style.left = x + 'px';
|
contextMenu.style.left = x + 'px';
|
||||||
@ -451,14 +447,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function contextAddStation() {
|
function contextAddStation() {
|
||||||
console.log('contextAddStation called');
|
const savedPosition = contextMenuPosition;
|
||||||
console.log('contextMenuPosition:', contextMenuPosition);
|
|
||||||
hideContextMenu();
|
hideContextMenu();
|
||||||
if (contextMenuPosition) {
|
if (savedPosition) {
|
||||||
console.log('Opening modal with position:', contextMenuPosition);
|
openAddStationModal(savedPosition);
|
||||||
openAddStationModal(contextMenuPosition);
|
|
||||||
} else {
|
|
||||||
console.log('No contextMenuPosition available');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,16 +561,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openAddStationModal(latlng = null) {
|
function openAddStationModal(latlng = null) {
|
||||||
console.log('openAddStationModal called with:', latlng);
|
|
||||||
document.getElementById('addModal').style.display = 'block';
|
document.getElementById('addModal').style.display = 'block';
|
||||||
if (latlng) {
|
if (latlng) {
|
||||||
console.log('Setting coordinates:', latlng.lat, latlng.lng);
|
|
||||||
document.getElementById('coordinates').value = `${latlng.lat.toFixed(6)}, ${latlng.lng.toFixed(6)}`;
|
document.getElementById('coordinates').value = `${latlng.lat.toFixed(6)}, ${latlng.lng.toFixed(6)}`;
|
||||||
if (tempMarker) {
|
if (tempMarker) {
|
||||||
map.removeLayer(tempMarker);
|
map.removeLayer(tempMarker);
|
||||||
}
|
}
|
||||||
tempMarker = L.marker(latlng).addTo(map);
|
tempMarker = L.marker(latlng).addTo(map);
|
||||||
console.log('Marker added to map');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,9 +723,6 @@
|
|||||||
const menuItem = document.getElementById('addStationMenuItem');
|
const menuItem = document.getElementById('addStationMenuItem');
|
||||||
if (menuItem) {
|
if (menuItem) {
|
||||||
menuItem.addEventListener('click', contextAddStation);
|
menuItem.addEventListener('click', contextAddStation);
|
||||||
console.log('Context menu event listener attached');
|
|
||||||
} else {
|
|
||||||
console.error('Could not find addStationMenuItem element');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user