From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/geolocation/clearwatch/index.html | 97 +++++++++++++++++++++ .../api/geolocation/getcurrentposition/index.html | 95 +++++++++++++++++++++ files/ja/web/api/geolocation/index.html | 75 ++++++++++++++++ .../web/api/geolocation/watchposition/index.html | 99 ++++++++++++++++++++++ 4 files changed, 366 insertions(+) create mode 100644 files/ja/web/api/geolocation/clearwatch/index.html create mode 100644 files/ja/web/api/geolocation/getcurrentposition/index.html create mode 100644 files/ja/web/api/geolocation/index.html create mode 100644 files/ja/web/api/geolocation/watchposition/index.html (limited to 'files/ja/web/api/geolocation') diff --git a/files/ja/web/api/geolocation/clearwatch/index.html b/files/ja/web/api/geolocation/clearwatch/index.html new file mode 100644 index 0000000000..6c4790a719 --- /dev/null +++ b/files/ja/web/api/geolocation/clearwatch/index.html @@ -0,0 +1,97 @@ +--- +title: Geolocation.clearWatch() +slug: Web/API/Geolocation/clearWatch +tags: + - API + - Geolocation + - Geolocation API + - Method + - Reference + - Secure context + - clearWatch + - メソッド + - リファレンス + - 位置情報 + - 位置情報 API + - 安全なコンテキスト +translation_of: Web/API/Geolocation/clearWatch +--- +

{{securecontext_header}}{{ APIref("Geolocation API") }}

+ +

Geolocation.clearWatch()メソッドは、以前 {{domxref("Geolocation.watchPosition()")}} によって登録された位置情報/エラーの監視ハンドラーを解除するために使用します。

+ +

構文

+ +
navigator.geolocation.clearWatch(id);
+ +

引数

+ +
+
id
+
解除したいハンドラーの登録時に {{domxref("Geolocation.watchPosition()")}} メソッドから返された ID 番号です。
+
+ +

+ +
var id, target, option;
+
+function success(pos) {
+  var crd = pos.coords;
+
+  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
+    console.log('Congratulation, you reach the target');
+    navigator.geolocation.clearWatch(id);
+  }
+};
+
+function error(err) {
+  console.warn('ERROR(' + err.code + '): ' + err.message);
+};
+
+target = {
+  latitude : 0,
+  longitude: 0,
+}
+
+options = {
+  enableHighAccuracy: false,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+id = navigator.geolocation.watchPosition(success, error, options);
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Geolocation.clearWatch")}}

+ +

関連情報

+ + diff --git a/files/ja/web/api/geolocation/getcurrentposition/index.html b/files/ja/web/api/geolocation/getcurrentposition/index.html new file mode 100644 index 0000000000..f99f1cef81 --- /dev/null +++ b/files/ja/web/api/geolocation/getcurrentposition/index.html @@ -0,0 +1,95 @@ +--- +title: Geolocation.getCurrentPosition() +slug: Web/API/Geolocation/getCurrentPosition +tags: + - API + - Geolocation + - Geolocation API + - Method + - Reference + - Secure context + - getCurrentPosition + - メソッド +translation_of: Web/API/Geolocation/getCurrentPosition +--- +

{{securecontext_header}}{{ APIRef("Geolocation API") }}

+ +

Geolocation.getCurrentPosition() メソッドは、デバイスの現在位置を取得するために使われます。

+ +

構文

+ +
navigator.geolocation.getCurrentPosition(success[, error[, [options]])
+ +

引数

+ +
+
success
+
コールバック関数で、 {{domxref("GeolocationPosition")}} オブジェクトを唯一の入力引数として受け取るものです。
+
error {{optional_inline}}
+
任意のコールバック関数で、 {{domxref("GeolocationPositionError")}} オブジェクトを唯一の入力引数として受け取るものです。
+
options {{optional_inline}}
+
任意の {{domxref("PositionOptions")}} オブジェクトです。
+ オプションには以下のものがあります。 +
    +
  • maximumAge: 整数 (ミリ秒) | infinity - キャッシュされた位置の最大寿命です。
  • +
  • timeout: 整数 (ミリ秒) - エラーコールバックが呼び出されるまでの時間で、 0 の場合は呼び出されません。
  • +
  • enableHighAccuracy: false | true
  • +
+
+
+ +

+ +
var options = {
+  enableHighAccuracy: true,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+function success(pos) {
+  var crd = pos.coords;
+
+  console.log('Your current position is:');
+  console.log(`Latitude : ${crd.latitude}`);
+  console.log(`Longitude: ${crd.longitude}`);
+  console.log(`More or less ${crd.accuracy} meters.`);
+}
+
+function error(err) {
+  console.warn(`ERROR(${err.code}): ${err.message}`);
+}
+
+navigator.geolocation.getCurrentPosition(success, error, options);
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Geolocation.getCurrentPosition")}}

+ +

関連情報

+ + diff --git a/files/ja/web/api/geolocation/index.html b/files/ja/web/api/geolocation/index.html new file mode 100644 index 0000000000..53163a84ee --- /dev/null +++ b/files/ja/web/api/geolocation/index.html @@ -0,0 +1,75 @@ +--- +title: Geolocation +slug: Web/API/Geolocation +tags: + - API + - Advanced + - Geolocation + - Geolocation API + - Interface + - Reference + - Secure context + - インターフェイス + - リファレンス + - 位置情報 + - 位置情報 API + - 安全なコンテキスト +translation_of: Web/API/Geolocation +--- +
{{securecontext_header}}{{APIRef("Geolocation API")}}
+ +

Geolocation インターフェイスはデバイスの位置を取得する機能を提供します。これにより、ウェブサイトやアプリがユーザーの現在の位置に応じた結果を提供できるようになります。

+ +

このインターフェイスを持つオブジェクトは、 {{domxref("Navigator")}} オブジェクトの {{domxref("navigator.geolocation")}} プロパティを使って得ることができます。

+ +
+

注: セキュリティ上の理由により、ウェブページが位置情報にアクセスしようとする時、ユーザーにアクセス許可が求められます。その方法やポリシーはブラウザーによって異なることに注意してください。

+
+ +

プロパティ

+ +

Geolocation インターフェイスが実装・継承するプロパティはありません。

+ +

メソッド

+ +

Geolocation インターフェイスが継承するプロパティはありません。

+ +
+
{{domxref("Geolocation.getCurrentPosition()")}} {{securecontext_inline}}
+
デバイスの現在位置を特定し、結果データを {{domxref("GeolocationPosition")}} オブジェクトで返します。
+
{{domxref("Geolocation.watchPosition()")}} {{securecontext_inline}}
+
デバイスの位置が変化する度に呼び出されるコールバック関数を登録し、それを識別する long 型の値を返します。
+
{{domxref("Geolocation.clearWatch()")}} {{securecontext_inline}}
+
watchPosition() によって以前に登録されたハンドラーを解除します。
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Geolocation', '#geolocation_interface')}}{{Spec2('Geolocation')}}初回定義。
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Geolocation")}}

+ +

関連情報

+ + diff --git a/files/ja/web/api/geolocation/watchposition/index.html b/files/ja/web/api/geolocation/watchposition/index.html new file mode 100644 index 0000000000..908f8b061d --- /dev/null +++ b/files/ja/web/api/geolocation/watchposition/index.html @@ -0,0 +1,99 @@ +--- +title: Geolocation.watchPosition() +slug: Web/API/Geolocation/watchPosition +tags: + - API + - Geolocation + - Geolocation API + - Method + - Reference + - Secure context +translation_of: Web/API/Geolocation/watchPosition +--- +

{{securecontext_header}}{{ APIref("Geolocation API") }}

+ +

{{domxref("Geolocation")}} の watchPosition() メソッドは、端末の位置が変化するたびに自動的に呼び出されるハンドラー関数を登録するために用いられます。また必要に応じてエラー処理コールバック関数を指定することができます。

+ +

構文

+ +
navigator.geolocation.watchPosition(success[, error[, options]])
+ +

引数

+ +
+
success
+
コールバック関数で、 {{domxref("GeolocationPosition")}} オブジェクトを入力引数として受け取るものです。
+
error {{optional_inline}}
+
任意のコールバック関数で、 {{domxref("GeolocationPositionError")}} オブジェクトを入力引数として受け取るものです。
+
options {{optional_inline}}
+
任意の {{domxref("PositionOptions")}} オブジェクトで、位置を監視する構成オプションを提供します。
+
+ +

返値

+ +

登録されたハンドラーを識別する ID を返します。この ID を {{domxref("Geolocation.clearWatch()")}} メソッドに渡してハンドラーの登録を解除することができます。

+ +

+ +
var id, target, options;
+
+function success(pos) {
+  var crd = pos.coords;
+
+  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
+    console.log('Congratulations, you reached the target');
+    navigator.geolocation.clearWatch(id);
+  }
+}
+
+function error(err) {
+  console.warn('ERROR(' + err.code + '): ' + err.message);
+}
+
+target = {
+  latitude : 0,
+  longitude: 0
+};
+
+options = {
+  enableHighAccuracy: false,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+id = navigator.geolocation.watchPosition(success, error, options);
+
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('Geolocation', '#dom-geolocation-watchposition', 'watchPosition()')}}{{Spec2('Geolocation')}}初回定義
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Geolocation.watchPosition")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf