Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Geolocation API

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

Geolocation API

Avatar for howdy39

howdy39

May 25, 2018
Tweet

More Decks by howdy39

Other Decks in Programming

Transcript

  1. success Function Position オブジェクトに位置情報が入っている function (position) { const latitude =

    position.coords.latitude; const longitude = position.coords.longitude; ... }
  2. error Function PositionError オブジェクトにエラーコードが入っている function (error) { const errorCode =

    error.code; } エラーコードは次の3つのどれか 1: 位置情報の利用が許可されていない 2: 位置が特定できない 3: タイムアウト
  3. geoOptions Object オプションは3つだけ const options = { enableHighAccuracy: false, //

    高精度の有効化 timeout: 5 * 1000, // タイムアウト(ms) maximumAge: 10 * 1000 // 位置情報の有効期限(ms) };
  4. Google Maps JavaScript API Google マップを使うAPI 使うには Cloud Console で

    API KEY を作ってJS読み込み時に 設定する <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDFbYxhyD8zKleiXY8 O7wxuRZvUGtJTldk&v=3.exp&sensor=false"></script>