Skip to content

Commit

Permalink
location
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfleis committed Jan 27, 2025
1 parent 14119f9 commit 82228b8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)}<br>Longitude: ${coordinates.lng.toFixed(5)}`)
.addTo(map);
});

// include zoom level indicator
// const zoomLevel = document.createElement('div');
// zoomLevel.id = 'zoom-level';
Expand Down

0 comments on commit 82228b8

Please sign in to comment.