From 1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde Mon Sep 17 00:00:00 2001 From: julieng Date: Sat, 2 Oct 2021 17:20:24 +0200 Subject: convert content to md --- .../fr/web/api/geolocation/watchposition/index.md | 92 +++++++++------------- 1 file changed, 37 insertions(+), 55 deletions(-) (limited to 'files/fr/web/api/geolocation/watchposition') diff --git a/files/fr/web/api/geolocation/watchposition/index.md b/files/fr/web/api/geolocation/watchposition/index.md index c2424f4774..71ed0cfc2c 100644 --- a/files/fr/web/api/geolocation/watchposition/index.md +++ b/files/fr/web/api/geolocation/watchposition/index.md @@ -10,35 +10,34 @@ tags: - Reference translation_of: Web/API/Geolocation/watchPosition --- -

{{ APIref("Geolocation API") }}

+{{ 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.

+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()")}}.

+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

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

Paramètres

+### 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")}}.
-
+- _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

+## Exemple -
var id, target, options;
+```js
+var id, target, options;
 
 function success(pos) {
   var crd = pos.coords;
 
-  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
+  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
     console.log('Bravo, vous avez atteint la cible');
     navigator.geolocation.clearWatch(id);
   }
@@ -60,41 +59,24 @@ options = {
 };
 
 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.
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - +``` + +> **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écification | Statut | Commentaire | +| -------------------------------------------------------------------------------------------------------- | -------------------------------- | ----------------------- | +| {{SpecName('Geolocation', '#watch-position', 'Geolocation.watchPosition()')}} | {{Spec2('Geolocation')}} | Specification initiale. | + +## Compatibilité des navigateurs + +{{Compat("api.Geolocation.watchPosition")}} + +## Voir aussi + +- [geolocation wake lock]() +- [Utiliser geolocation](/fr/docs/WebAPI/Using_geolocation) +- L'interface qui lui est réservée, {{domxref("Geolocation")}}, et la façon d'y accéder {{domxref("NavigatorGeolocation.geolocation")}}. +- L'opération inverse : {{domxref("Geolocation.clearWatch()")}} +- Une méthode similaire : {{domxref("Geolocation.getCurrentPosition()")}} -- cgit v1.2.3-54-g00ecf