diff --git a/aisome_car_color.png b/aisome_car_color.png new file mode 100644 index 0000000..d57fa14 --- /dev/null +++ b/aisome_car_color.png Binary files differ diff --git a/domon.js b/domon.js index 8d22bc2..2d0310c 100644 --- a/domon.js +++ b/domon.js @@ -1,15 +1,13 @@ /* domon.js - 北緯38.891度, 東経139.824度, ズームレベル16 で地図表示 */ var mymap = L.map("hogemap").setView([38.891, 139.824], 16); - L.tileLayer('https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png', { - attribution: - '© 国土地理院 contributors' + L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', { + attribution:'© OpenStreetMap contributors', }).addTo(mymap); L.control.scale().addTo(mymap); - mymap.on("click", (e) => { - var maru = L.circle(e.latlng, 20); //まず変数に保存 - setTimeout(() => {maru.remove();}, 3000); //3000ミリ秒経ったら消す - maru.addTo(mymap); - var newh1 = "北緯" + e.latlng.lat + ", 東経"+e.latlng.lng; - document.getElementById("latlng").textContent = newh1; - }); + var mymap = L.map("gpsmap").setView([38.891, 139.824], 16); + var myIcon = L.icon({ + iconUrl: '[aisome_car_color.png]', + iconSize: [38, 95] // アイコンサイズ + }); + L.marker([38.891, 139.824], {icon: myIcon}).addTo(map); diff --git a/map/gps/gps-chase.html b/map/gps/gps-chase.html index 077e8d7..9e187a7 100644 --- a/map/gps/gps-chase.html +++ b/map/gps/gps-chase.html @@ -17,7 +17,7 @@

-src +src

diff --git a/map/gps/gps-chase2.html b/map/gps/gps-chase2.html deleted file mode 100644 index 077e8d7..0000000 --- a/map/gps/gps-chase2.html +++ /dev/null @@ -1,26 +0,0 @@ - - - -GPS宝探し - - - - - - - -

たからさがし

-

- - -src -

-
- - - - diff --git a/map/gps/gps-chase2.js b/map/gps/gps-chase2.js deleted file mode 100644 index 4a62a38..0000000 --- a/map/gps/gps-chase2.js +++ /dev/null @@ -1,53 +0,0 @@ -document.addEventListener("DOMContentLoaded", () => { - var mymap = L.map("gpsmap").setView([38.891, 139.824], 16); - L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', { - attribution: - '© OpenStreetMap \ - contributors' - }).addTo(mymap); - - var gpsmarker = L.marker(mymap.getCenter()).addTo(mymap); - gpsmarker.bindPopup("STARTおしてね").openPopup(); - - var nTrial = 100 - var watchId = null; // 最初はnullにしておく - function stopGPS() { // watchが動いていたら止めてnullにする - console.log("watchId="+watchId); - if (watchId != null) { // nullかどうかで比較しないとだめ(初期値0) - navigator.geolocation.clearWatch(watchId); - document.getElementById("title").textContent = "stop"; - gpsmarker.setPopupContent("停めました"); - } - watchId = null; - } - function tryWatchGPS() { - stopGPS(); // 二重で動かないように注意する - watchId = navigator.geolocation.watchPosition( - onSuccess, onError,{ - maximumAge: 0, timeout: 3000, enableHighAccuracy: true}); - document.getElementById("title").textContent = "START!!"; - } - function onSuccess(pos) { // GPS信号が取れたらここに来る - var latlng = L.latLng([pos.coords.latitude, pos.coords.longitude]); - mymap.panTo(latlng);// 地図の中心をそこにする - console.log(latlng); - // ★★★★★ ここから - gpsmarker.setLatLng(latlng).setPopupContent( - "ここは lat="+latlng.lat+", lng="+latlng.lng+" です." - ).openPopup(); - // ★★★★★ ここまでの latlng.lat と latlng.lng を - // if文などで判定して、特定の場所に近づいたら「GOAL!」と - // 表示するように変えてみよ。 - } - function onError(err) { - restN = "あと"+(--nTrial)+"回試行します。"; - gpsmarker.setPopupContent("捕捉失敗:"+restN).openPopup(); - if (nTrial <= 0) { - navigator.geolocation.clearWatch(watchId); - } - } - // STARTボタンに開始を仕込む - document.getElementById("start").addEventListener("click", tryWatchGPS); - // STOPボタンに停止を仕込む - document.getElementById("stop").addEventListener("click", stopGPS); -}, false); diff --git a/map/gps/gpsgame.html b/map/gps/gpsgame.html new file mode 100644 index 0000000..e3beff7 --- /dev/null +++ b/map/gps/gpsgame.html @@ -0,0 +1,30 @@ + + + +GPS宝探し + + + + + + + +

たからさがし

+

+ + +src +

+
+ + + + diff --git a/map/gps/gpsgame.js b/map/gps/gpsgame.js new file mode 100644 index 0000000..4a62a38 --- /dev/null +++ b/map/gps/gpsgame.js @@ -0,0 +1,53 @@ +document.addEventListener("DOMContentLoaded", () => { + var mymap = L.map("gpsmap").setView([38.891, 139.824], 16); + L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', { + attribution: + '© OpenStreetMap \ + contributors' + }).addTo(mymap); + + var gpsmarker = L.marker(mymap.getCenter()).addTo(mymap); + gpsmarker.bindPopup("STARTおしてね").openPopup(); + + var nTrial = 100 + var watchId = null; // 最初はnullにしておく + function stopGPS() { // watchが動いていたら止めてnullにする + console.log("watchId="+watchId); + if (watchId != null) { // nullかどうかで比較しないとだめ(初期値0) + navigator.geolocation.clearWatch(watchId); + document.getElementById("title").textContent = "stop"; + gpsmarker.setPopupContent("停めました"); + } + watchId = null; + } + function tryWatchGPS() { + stopGPS(); // 二重で動かないように注意する + watchId = navigator.geolocation.watchPosition( + onSuccess, onError,{ + maximumAge: 0, timeout: 3000, enableHighAccuracy: true}); + document.getElementById("title").textContent = "START!!"; + } + function onSuccess(pos) { // GPS信号が取れたらここに来る + var latlng = L.latLng([pos.coords.latitude, pos.coords.longitude]); + mymap.panTo(latlng);// 地図の中心をそこにする + console.log(latlng); + // ★★★★★ ここから + gpsmarker.setLatLng(latlng).setPopupContent( + "ここは lat="+latlng.lat+", lng="+latlng.lng+" です." + ).openPopup(); + // ★★★★★ ここまでの latlng.lat と latlng.lng を + // if文などで判定して、特定の場所に近づいたら「GOAL!」と + // 表示するように変えてみよ。 + } + function onError(err) { + restN = "あと"+(--nTrial)+"回試行します。"; + gpsmarker.setPopupContent("捕捉失敗:"+restN).openPopup(); + if (nTrial <= 0) { + navigator.geolocation.clearWatch(watchId); + } + } + // STARTボタンに開始を仕込む + document.getElementById("start").addEventListener("click", tryWatchGPS); + // STOPボタンに停止を仕込む + document.getElementById("stop").addEventListener("click", stopGPS); +}, false);