Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (57 sloc) 3.32 KB

Rx.DOM.geolocation.watchPosition([geolocationOptions])

Begins listening for updates to the current geographical location of the device running the client.

Arguments

  1. [geolocationOptions] (Object): An object literal to specify one or more of the following attributes and desired values:
    • enableHighAccuracy: Specify true to obtain the most accurate position possible, or false to optimize in favor of performance and power consumption.
    • timeout: An Integer value that indicates the time, in milliseconds, allowed for obtaining the position. If timeout is Infinity, (the default value) the location request will not time out. If timeout is zero (0) or negative, the results depend on the behavior of the location provider.
    • maximumAge: An Integer value indicating the maximum age, in milliseconds, of cached position information. If maximumAge is non-zero, and a cached position that is no older than maximumAge is available, the cached position is used instead of obtaining an updated location. If maximumAge is zero (0), watchPosition always tries to obtain an updated position, even if a cached position is already available. If maximumAge is Infinity, any cached position is used, regardless of its age, and watchPosition only tries to obtain an updated position if no cached position data exists.

Returns

(Observable): An observable sequence with the current geographical location of the device running the client.

Example

var source = Rx.DOM.geolocation.watchPosition();

var subscription = source.subscribe(
  function (pos) {
    console.log('Next:' + position.coords.latitude + ',' + position.coords.longitude);
  },
  function (err) {
    var message = '';
    switch (err.code) {
      case err.PERMISSION_DENIED:
        message = 'Permission denied';
        break;
      case err.POSITION_UNAVAILABLE:
        message = 'Position unavailable';
        break;
      case err.PERMISSION_DENIED_TIMEOUT:
        message = 'Position timeout';
        break;
    }
    console.log('Error: ' + message);
  },
  function () {
    console.log('Completed');
  });

Location

File:

Dist:

Prerequisites:

NPM Packages:

NuGet Packages:

Unit Tests:

You can’t perform that action at this time.