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/fr/web/api/geolocation/clearwatch/index.html | 143 +++++++++++++++++++ .../api/geolocation/getcurrentposition/index.html | 90 ++++++++++++ files/fr/web/api/geolocation/index.html | 120 ++++++++++++++++ .../web/api/geolocation/watchposition/index.html | 155 +++++++++++++++++++++ 4 files changed, 508 insertions(+) create mode 100644 files/fr/web/api/geolocation/clearwatch/index.html create mode 100644 files/fr/web/api/geolocation/getcurrentposition/index.html create mode 100644 files/fr/web/api/geolocation/index.html create mode 100644 files/fr/web/api/geolocation/watchposition/index.html (limited to 'files/fr/web/api/geolocation') diff --git a/files/fr/web/api/geolocation/clearwatch/index.html b/files/fr/web/api/geolocation/clearwatch/index.html new file mode 100644 index 0000000000..b60b0df663 --- /dev/null +++ b/files/fr/web/api/geolocation/clearwatch/index.html @@ -0,0 +1,143 @@ +--- +title: Geolocation.clearWatch() +slug: Web/API/Geolocation/clearWatch +tags: + - API + - Besoin d'exemple + - Géolocalisation + - Géolocalisation API + - Méthode + - Reference +translation_of: Web/API/Geolocation/clearWatch +--- +

{{ APIref("Geolocation API") }}

+ +

La méthode Geolocation.clearWatch() est utilisée pour libérer les ressources de localisation/erreur créées antérieurement en utilisant {{domxref("Geolocation.watchPosition()")}}.

+ +

Syntaxe

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

Paramètres

+ +
+
id
+
Le nombre ID est donné par la méthode qui permet la localisation : {{domxref("Geolocation.watchPosition()")}} ; ressource que vous désirez supprimer.
+
+ +

Exemple

+ +
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);
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}Spécification initiale.
+ +

Compatibilité des navigateurs

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaractéristiqueChromeLimiteFirefox (Gecko)Internet ExplorerOperaSafari
Basic support5{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.9.1")}}910.60
+ Supprimé en 15.0
+ Réintroduite en 16.0
5
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
CaractéristiqueAndroidChrome pour AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown()}}{{CompatUnknown()}}{{CompatVersionUnknown}}{{CompatGeckoMobile("4")}}{{CompatUnknown()}}10.60{{CompatUnknown()}}
+
+ +

Voir également

+ + diff --git a/files/fr/web/api/geolocation/getcurrentposition/index.html b/files/fr/web/api/geolocation/getcurrentposition/index.html new file mode 100644 index 0000000000..25c0c9d97c --- /dev/null +++ b/files/fr/web/api/geolocation/getcurrentposition/index.html @@ -0,0 +1,90 @@ +--- +title: Geolocation.getCurrentPosition() +slug: Web/API/Geolocation/getCurrentPosition +tags: + - API + - Geolocation + - Méthode + - Reference +translation_of: Web/API/Geolocation/getCurrentPosition +--- +
{{securecontext_header}}{{APIRef("Geolocation API")}}
+ +

La méthode Geolocation.getCurrentPosition() fournit la position actuelle de l'appareil.

+ +

Syntaxe

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

Paramètres

+ +
+
success
+
Une fonction de rappel qui prend un objet {{domxref("Position")}} comme argument.
+
error {{optional_inline}}
+
Une fonction de rappel qui prend un objet {{domxref("PositionError")}} comme argument.
+
options {{optional_inline}}
+
Un objet {{domxref("PositionOptions")}} optionnel. Les options décrites par cet objet sont : +
    +
  • maximumAge : un entier qui exprime une durée en millisecondes ou l'infini pour indiquer la durée maximale pendant laquelle mettre en cache la position.
  • +
  • timeout : un entier qui exprime la durée, en millisecondes, avant que la fonction de rappel error soit appelé. Si cette propriété vaut 0, la fonction d'erreur ne sera jamais appelée.
  • +
  • enableHighAccuracy : un booléen qui indique si une précision élevée est requise.
  • +
+
+
+ +

Exemples

+ +
var options = {
+  enableHighAccuracy: true,
+  timeout: 5000,
+  maximumAge: 0
+};
+
+function success(pos) {
+  var crd = pos.coords;
+
+  console.log('Votre position actuelle est :');
+  console.log(`Latitude : ${crd.latitude}`);
+  console.log(`Longitude : ${crd.longitude}`);
+  console.log(`La précision est de ${crd.accuracy} mètres.`);
+}
+
+function error(err) {
+  console.warn(`ERREUR (${err.code}): ${err.message}`);
+}
+
+navigator.geolocation.getCurrentPosition(success, error, options);
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}Spécification initiale.
+ +

Compatibilité des navigateurs

+ + + +

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

+ +

Voir aussi

+ + diff --git a/files/fr/web/api/geolocation/index.html b/files/fr/web/api/geolocation/index.html new file mode 100644 index 0000000000..0dd4b6917a --- /dev/null +++ b/files/fr/web/api/geolocation/index.html @@ -0,0 +1,120 @@ +--- +title: Geolocation +slug: Web/API/Geolocation +tags: + - API + - Avancé + - Géolocalisation API + - Interface + - Reference +translation_of: Web/API/Geolocation +--- +
{{APIRef("Geolocation API")}}
+ +

En intégrant l'interface Geolocation, on peut obtenir la position d'un ordinateur, d'un téléphone ou d'une tablette, ce qui permet aux contenus Web d'accéder à leur localisation. Un site internet ou une application mobile peut alors offrir divers services liés à la localisation de l'utilisateur.

+ +

On obtient un objet par le biais de cette interface avec la propriété {{domxref("NavigatorGeolocation.geolocation")}} proposée par l'objet {{domxref("Navigator")}} .

+ +
+

Note: Pour des raisons de sécurité, quand une page web tente d'accéder aux données de localisation, l'utilisateur est prévenu, et son accord lui est demandé. Sachez que chaque navigateur a ses propres méthodes et politiques pour gérer les autorisations.

+
+ +

Propriétés

+ +

L'interface de géolocalisation n'utilise ou n'hérite d'aucune propriété.

+ +

Méthodes

+ +

L'interface de géolocalisation n'hérite d'aucune méthode.

+ +
+
{{domxref("Geolocation.getCurrentPosition()")}}
+
Determine la position actuelle de l'appareil et donne en retour l'objet {{domxref("Position")}} avec sa valeur.
+
{{domxref("Geolocation.watchPosition()")}}
+
Retourne une valeur long représentant la nouvelle fonction callback, créée pour être utilisée à chaque fois que la position de l'appareil change.
+
{{domxref("Geolocation.clearWatch()")}}
+
Supprime le lien créé par la précédente utilisation de watchPosition().
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Geolocation')}}{{Spec2('Geolocation')}}Spécification initiale.
+ +

Compatibilité des navigateurs

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaractéristiqueChromeLimiteFirefox (Gecko)Internet ExplorerOperaSafari
Basic support5{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.9.1")}}910.60
+ Removed in 15.0
+ Reintroduced in 16.0
5
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
CaractéristiqueAndroidChrome pour AndroidLimiteFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown()}}{{CompatUnknown()}}{{CompatVersionUnknown}}{{CompatGeckoMobile("4")}}{{CompatUnknown()}}10.60{{CompatUnknown()}}
+
+ +

Voir également

+ + diff --git a/files/fr/web/api/geolocation/watchposition/index.html b/files/fr/web/api/geolocation/watchposition/index.html new file mode 100644 index 0000000000..00b5d17796 --- /dev/null +++ b/files/fr/web/api/geolocation/watchposition/index.html @@ -0,0 +1,155 @@ +--- +title: Geolocation.watchPosition() +slug: Web/API/Geolocation/watchPosition +tags: + - API + - Exemple + - Géolocalisation + - Géolocalisation API + - Méthode + - Reference +translation_of: Web/API/Geolocation/watchPosition +--- +

{{ APIref("Geolocation API") }}

+ +

La méthode Geolocation.watchPosition() permet de manipuler une fonction appelée automatiquement à chaque fois que la position de l'appareil change. Vous pouvez de même, en option, manipuler une autre fonction appelée automatiquement pour gérer les erreurs.

+ +

Cette méthode retourne une valeur ID de veille qui permet de libérer les fonctions déclarées automatiquement, évoquées précédemment, à l'aide de la méthode {{domxref("Geolocation.clearWatch()")}}.

+ +

Syntaxe

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

Paramètres

+ +
+
success
+
Nom d'une fonction appelée qui a pour paramètre l'objet {{domxref("Position")}}.
+
error {{optional_inline}}
+
Nom d'une fonction optionnelle qui a pour paramètre l'objet {{domxref("PositionError")}}.
+
options {{optional_inline}}
+
Un objet optionnel {{domxref("PositionOptions")}}.
+
+ +

Exemple

+ +
var id, target, options;
+
+function success(pos) {
+  var crd = pos.coords;
+
+  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
+    console.log('Bravo, vous avez atteint la cible');
+    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);
+
+ +
Note : Si votre application fonctionne sous Firefox OS, veillez à la geolocation wake lock pour que votre application continue à recevoir les changements de positions si votre application tourne en tâche de fond, ou si votre écran est éteint. + +

 

+
+ +

Spécifications

+ + + + + + + + + + + + + + + + +
SpécificationStatutCommentaire
{{SpecName('Geolocation', '#watch-position', 'Geolocation.watchPosition()')}}{{Spec2('Geolocation')}}Specification initiale.
+ + + +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaractèreChromeLimiteFirefox (Gecko)Internet ExplorerOperaSafari
Basic support5{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.9.1")}}910.60
+ Supprimé de 15.0
+ Réintroduit en 16.0
5
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
CaractèreAndroidChrome pour AndroidLimiteFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown()}}{{CompatUnknown()}}{{CompatVersionUnknown}}{{CompatGeckoMobile("4")}}{{CompatUnknown()}}10.60{{CompatUnknown()}}
+
+ +

Voir également

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