Skip to content

Commit

Permalink
Add mouse coord
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn committed Sep 11, 2023
1 parent fb17341 commit 4e2b40c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/handler/template/click.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
</head>
<body>
<div id="map"></div>
<span
id="mousecoord"
style="
display: block;
position: absolute;
right: 0;
top: 0;
z-index: 9999;
background-color: white;
"
></span>

<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script>
Expand All @@ -33,6 +44,7 @@
worldCopyJump: true,
maxZoom: 18,
minZoom: 3,
cursor: true,
}).setView([40.7128, -74.006], 5);

L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
Expand All @@ -44,6 +56,14 @@
var markers = [];
var polygons = [];

map.on("mousemove", function (e) {
var lng = e.latlng.wrap().lng.toFixed(4);
var lat = e.latlng.wrap().lat.toFixed(4);
document.getElementById(
"mousecoord"
).innerHTML = `Lat: ${lat} Lng: ${lng}`;
});

map.on("click", function (e) {
var lng = e.latlng.wrap().lng.toFixed(4);
var lat = e.latlng.wrap().lat.toFixed(4);
Expand Down

0 comments on commit 4e2b40c

Please sign in to comment.