0
0

More than 3 years have passed since last update.

HPFメモ_現在地の緯度経度を取得

Posted at

Geolocation API というやつで取得できる。

よく、WEBページで 現在地取得していいすか?ってでるやつのようだ。

↓へー 
image.png

↓へーーー
getCurrentPosition() …… ユーザーの現在の位置情報を一回だけ取得する
watchPosition() …… ユーザーの位置情報を定期的に監視する
clearWatch() …… watchPosition()による位置情報の監視をクリアする

//ユーザーの現在の位置情報を取得
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);

/***** ユーザーの現在の位置情報を取得 *****/
function successCallback(position) {
var gl_text = "緯度:" + position.coords.latitude + "
";
gl_text += "経度:" + position.coords.longitude + "
";
gl_text += "高度:" + position.coords.altitude + "
";
gl_text += "緯度・経度の誤差:" + position.coords.accuracy + "
";
gl_text += "高度の誤差:" + position.coords.altitudeAccuracy + "
";
gl_text += "方角:" + position.coords.heading + "
";
gl_text += "速度:" + position.coords.speed + "
";
document.getElementById("show_result").innerHTML = gl_text;
}

latitude …… 緯度(-180~180、単位:度)
longitude …… 経度(-90~90、単位:度)
altitude …… 高度(単位:m)
accuracy …… 緯度・経度の誤差(単位:m)
altitudeAccuracy …… 高度の誤差(単位:m)
heading …… 方角(0~360、単位:度)
speed …… 速度(単位:m/秒)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0