0
0

Webで現在地取得

Posted at

webで現在地を取得します
こちらの参考サイトよりコードを引用します。

navigator.geolocation.getCurrentPosition(function(position) {
  var latitude = position.coords.latitude;
  var longitude = position.coords.longitude;
  console.log("緯度:" + latitude + ", 経度:" + longitude);
  // 緯度:30.0000000, 経度:130.0000000
});

私の場合は小数点第7位まで測定できました。
緯度と経度から現在地を調べられるサイトを使用しましたが、誤差数メートルです。かなり細い位置まで取得できるんですね。

参考

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