diff options
author | julieng <julien.gattelier@gmail.com> | 2021-10-02 17:20:24 +0200 |
---|---|---|
committer | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-10-02 17:30:20 +0200 |
commit | 1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde (patch) | |
tree | 30a56efd3eff3a01bd1611e1840fdbbfacf544a4 /files/fr/web/api/geolocation/watchposition | |
parent | c05efa8d7ae464235cf83d7c0956e42dc6974103 (diff) | |
download | translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.tar.gz translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.tar.bz2 translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.zip |
convert content to md
Diffstat (limited to 'files/fr/web/api/geolocation/watchposition')
-rw-r--r-- | files/fr/web/api/geolocation/watchposition/index.md | 92 |
1 files changed, 37 insertions, 55 deletions
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 --- -<p>{{ APIref("Geolocation API") }}</p> +{{ APIref("Geolocation API") }} -<p>La méthode <strong><code>Geolocation.watchPosition()</code></strong> 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.</p> +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. -<p>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()")}}.</p> +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()")}}. -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="syntaxbox"><em>id</em> = navigator.geolocation.watchPosition(<em>success[</em>, <em>error[</em>, <em>options]]</em>)</pre> + id = navigator.geolocation.watchPosition(success[, error[, options]]) -<h3 id="Paramètres">Paramètres</h3> +### Paramètres -<dl> - <dt><em>success</em></dt> - <dd>Nom d'une fonction appelée qui a pour paramètre l'objet {{domxref("Position")}}.</dd> - <dt><em>error</em> {{optional_inline}}</dt> - <dd>Nom d'une fonction optionnelle qui a pour paramètre l'objet {{domxref("PositionError")}}.</dd> - <dt><em>options</em> {{optional_inline}}</dt> - <dd>Un objet optionnel {{domxref("PositionOptions")}}.</dd> -</dl> +- _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")}}. -<h2 id="Exemple">Exemple</h2> +## Exemple -<pre class="brush: js">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); -</pre> - -<div class="note"> - <p><strong>Note :</strong> Si votre application fonctionne sous Firefox OS, veillez à la <a href="/en-US/docs/Web/API/Geolocation/navigator.requestWakeLock()">geolocation wake lock</a> 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.</p> -</div> - -<h2 id="Spécifications">Spécifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Spécification</th> - <th scope="col">Statut</th> - <th scope="col">Commentaire</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Geolocation', '#watch-position', 'Geolocation.watchPosition()')}}</td> - <td>{{Spec2('Geolocation')}}</td> - <td>Specification initiale.</td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Compatibilité des navigateurs</h2> - -<p>{{Compat("api.Geolocation.watchPosition")}}</p> - -<h2 id="See_also">Voir aussi</h2> - -<ul> - <li><a href="/fr/docs/Web/API/Geolocation/navigator.requestWakeLock()">geolocation wake lock</a></li> - <li><a href="/fr/docs/WebAPI/Using_geolocation">Utiliser geolocation</a></li> - <li>L'interface qui lui est réservée, {{domxref("Geolocation")}}, et la façon d'y accéder {{domxref("NavigatorGeolocation.geolocation")}}.</li> - <li>L'opération inverse : {{domxref("Geolocation.clearWatch()")}}</li> - <li>Une méthode similaire : {{domxref("Geolocation.getCurrentPosition()")}}</li> -</ul> +``` + +> **Note :** Si votre application fonctionne sous Firefox OS, veillez à la [geolocation wake lock](</en-US/docs/Web/API/Geolocation/navigator.requestWakeLock()>) 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](</fr/docs/Web/API/Geolocation/navigator.requestWakeLock()>) +- [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()")}} |