pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: https://developer.mozilla.org/ja/docs/Web/API/HTMLGeolocationElement/position

pt src="/static/client/1111.53dba753dc3eb961.js" type="module">

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

HTMLGeolocationElement: position プロパティ

positionHTMLGeolocationElement インターフェイスの読み取り専用プロパティで、位置データの取得に成功した場合、ユーザーの現在地を表す GeolocationPosition オブジェクトを返します。

取得された位置情報は、最新である場合もあればそうでない場合もあります。<geolocation> 要素のボタンコントロールが押された際にのみ、ユーザーの位置情報が一度取得されます。ただし、watch 属性を true に設定した場合、ユーザー端末が移動するたびに新しい位置情報が取得されます。ユーザーの現在位置を読み取るには、location イベントが発生した際に position プロパティを参照する必要があります。

位置情報の取得に失敗した場合、関連付けられたエラー情報は HTMLGeolocationElement.error プロパティで取得できます。

GeolocationPosition オブジェクトです。位置データの取得に失敗した場合や、データがまだ取得されていない場合は null です。

基本的な使い方

html
<geolocation autolocate></geolocation>
js
const geo = document.querySelector("geolocation");
geo.addEventListener("location", () => {
  if (geo.position) {
    console.log(
      `(${geo.position.coords.latitude},${geo.position.coords.longitude})`,
    );
  } else if (geo.error) {
    console.log(geo.error.message);
  }
});

position を含む実際の例については、組み込み地図の例の手順を追っての説明をご覧ください。

仕様書

Specification
The HTML Permission Elements
# dom-htmlgeolocationelement-position

ブラウザーの互換性

関連情報

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy