diff --git a/loc-chase2.js b/loc-chase2.js index 461fb96..630ed03 100644 --- a/loc-chase2.js +++ b/loc-chase2.js @@ -1,4 +1,5 @@ document.addEventListener("DOMContentLoaded", () => { + var mymap = L.map("locationmap").setView([38.891, 139.824], 16); L.tileLayer("https://{s}.tile.osm.org/{z}/{x}/{y}.png", { @@ -32,10 +33,12 @@ document.getElementById("title").textContent = "START!!"; } + function updateLocation(lat, lng) { const latlng = L.latLng(lat, lng); mymap.panTo(latlng); + // ゴール位置 const goalLat = 38.892; const goalLng = 139.825; @@ -73,6 +76,7 @@ } } + mymap.on("click", function (e) { updateLocation( e.latlng.lat, @@ -80,7 +84,7 @@ ); }); - + document.getElementById("start") .addEventListener("click", tryWatchLOC);