From 82228b88fc3371509c5d53c07af856e35766d873 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Mon, 27 Jan 2025 10:05:31 +0100 Subject: [PATCH] location --- index.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.html b/index.html index c462055..e78e7be 100644 --- a/index.html +++ b/index.html @@ -800,6 +800,15 @@ let nav = new maplibregl.NavigationControl(); map.addControl(nav, 'top-left'); + // Add right-click event listener to show latitude and longitude + map.on('contextmenu', function (e) { + const coordinates = e.lngLat; + new maplibregl.Popup() + .setLngLat(coordinates) + .setHTML(`Latitude: ${coordinates.lat.toFixed(5)}
Longitude: ${coordinates.lng.toFixed(5)}`) + .addTo(map); + }); + // include zoom level indicator // const zoomLevel = document.createElement('div'); // zoomLevel.id = 'zoom-level';