diff --git a/map/game/game.html b/map/game/game.html index 29f0b49..3fb3a7b 100644 --- a/map/game/game.html +++ b/map/game/game.html @@ -18,7 +18,8 @@

- 使用方法 -

「start」で計測開始

「stop」で計測終了

-

「now」で計測開始地点から現在地点までの距離を表示

+

「now」で現在地点を表示

+

「result」で歩行距離を表示

「src」でソースコードを表示

@@ -39,8 +40,12 @@
+ +
+
+ f diff --git a/map/game/game.js b/map/game/game.js index 7453d90..c8d0251 100644 --- a/map/game/game.js +++ b/map/game/game.js @@ -53,7 +53,7 @@ watchId = navigator.geolocation.watchPosition( onGood, onError,{ maximumAge: 0, timeout: 3000, enableHighAccuracy: true}); - document.getElementById("timer").textContent = "現在地です"; + document.getElementById("timer").textContent = "現在地はここ!"; } function onGood(pos) { // nowGPSでGPS信号が取れたらここに来る @@ -65,20 +65,8 @@ ).openPopup(); x2 = latlng.lat,y2 = latlng.lng; distance(x1, y1, x2, y2); - console.log(distance); } - function distance(x1, y1, x2, y2) { - x1 *= r;//乗算代入 - y1 *= r; - x2 *= r; - y2 *= r; - var dis = (6371 * Math.acos(Math.cos(x1) * Math.cos(x2) * Math.cos(y2 - y1) + Math.sin(x1) * Math.sin(x2)))*1000; - //地球を半径6,371kmの球体としたときの計算。Google mapと同じ計算...らしい - all += Math.floor(dis * 10) / 10; - console.log(all); -} - function onError(err) { restN = "あと"+(--nTrial)+"回試行します。"; gpsmarker.setPopupContent("捕捉失敗:"+restN).openPopup(); @@ -88,10 +76,23 @@ } function result(){ - document.getElementById("timer").textContent = "お疲れ様!歩いた距離がポップアップで出るよ!"; + function distance(x1, y1, x2, y2) { + x1 *= r;//乗算代入 + y1 *= r; + x2 *= r; + y2 *= r; + var dis = (6371 * Math.acos(Math.cos(x1) * Math.cos(x2) * Math.cos(y2 - y1) + Math.sin(x1) * Math.sin(x2)))*1000; + //地球を半径6,371kmの球体としたときの計算。Google mapと同じ計算...らしい + all += Math.floor(dis * 10) / 10; + console.log(all); + } + document.getElementById("timer").textContent = "お疲れ^^ どれくらい歩いたかな"; gpsmarker.setPopupContent("今回の歩行距離は"+all).openPopup(); + watchId = null; } + document.getElementById("start").addEventListener("click", tryWatchGPS); document.getElementById("stop").addEventListener("click", stopGPS); document.getElementById("now").addEventListener("click", nowGPS); + document.getElementById("result").addEventListener("click", result); }, false); \ No newline at end of file