Classdesc

Helper class for providing HTML5 Geolocation capabilities. The Geolocation API is used to locate a user's position.

To get notified of position changes, register a listener for the generic change event on your instance of ol.Geolocation.

Example:

var geolocation = new ol.Geolocation({
// take the projection to use from the map's view
projection: view.getProjection()
});
// listen to changes in position
geolocation.on('change', function(evt) {
window.console.log(geolocation.getPosition());
});

Fires

error

Param: opt_options

Options.

Api

stable

Hierarchy

Constructors

  • Parameters

    Returns Geolocation

    Classdesc

    Helper class for providing HTML5 Geolocation capabilities. The Geolocation API is used to locate a user's position.

    To get notified of position changes, register a listener for the generic change event on your instance of ol.Geolocation.

    Example:

    var geolocation = new ol.Geolocation({
    // take the projection to use from the map's view
    projection: view.getProjection()
    });
    // listen to changes in position
    geolocation.on('change', function(evt) {
    window.console.log(geolocation.getPosition());
    });

    Fires

    error

    Api

    stable

Methods

  • Increases the revision counter and dispatches a 'change' event.

    Returns void

    Api

  • Dispatches an event and calls all listeners listening for events of this type. The event parameter can either be a string or an Object with a type property.

    Parameters

    Returns void

    Function

    Api

  • Gets a value.

    Parameters

    • key: string

      Key name.

    Returns any

    Value.

    Api

    stable

  • Get the accuracy of the position in meters.

    Returns number

    The accuracy of the position measurement in meters.

    Observable

    Api

    stable

  • Get a geometry of the position accuracy.

    Returns ol.geom.Geometry

    A geometry of the position accuracy.

    Observable

    Api

    stable

  • Get the altitude associated with the position.

    Returns number

    The altitude of the position in meters above mean sea level.

    Observable

    Api

    stable

  • Get the altitude accuracy of the position.

    Returns number

    The accuracy of the altitude measurement in meters.

    Observable

    Api

    stable

  • Get the heading as radians clockwise from North.

    Returns number

    The heading of the device in radians from north.

    Observable

    Api

    stable

  • Get a list of object property names.

    Returns string[]

    List of property names.

    Api

    stable

  • Get the position of the device.

    Returns Coordinate

    The current position of the device reported in the current projection.

    Observable

    Api

    stable

  • Get the projection associated with the position.

    Returns Projection

    The projection the position is reported in.

    Observable

    Api

    stable

  • Get an object of all property names and values.

    Returns {
        [k: string]: any;
    }

    Object.

    • [k: string]: any

    Api

    stable

  • Get the version number for this object. Each time the object is modified, its version number will be incremented.

    Returns number

    Revision.

    Api

  • Get the speed in meters per second.

    Returns number

    The instantaneous speed of the device in meters per second.

    Observable

    Api

    stable

  • Determine if the device location is being tracked.

    Returns boolean

    The device location is being tracked.

    Observable

    Api

    stable

  • Listen for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object to use as this in listener.

    Returns Object | Object[]

    Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

    Api

    stable

  • Listen once for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object to use as this in listener.

    Returns Object | Object[]

    Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

    Api

    stable

  • Sets a value.

    Parameters

    • key: string

      Key name.

    • value: any

      Value.

    • Optional opt_silent: boolean

      Update without triggering an event.

    Returns void

    Api

    stable

  • Set the projection to use for transforming the coordinates.

    Parameters

    • projection: Projection

      The projection the position is reported in.

    Returns void

    Observable

    Api

    stable

  • Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).

    Parameters

    • values: {
          [k: string]: any;
      }

      Values.

      • [k: string]: any
    • Optional opt_silent: boolean

      Update without triggering an event.

    Returns void

    Api

    stable

  • Enable or disable tracking.

    Parameters

    • tracking: boolean

      Enable tracking.

    Returns void

    Observable

    Api

    stable

  • Unlisten for a certain type of event.

    Parameters

    • type: string | string[]

      The event type or array of event types.

    • listener: Function

      The listener function.

    • Optional opt_this: Object

      The object which was used as this by the listener.

    Returns void

    Api

    stable

  • Removes an event listener using the key returned by on() or once(). Note that using the ol.Observable.unByKey static function is to be preferred.

    Parameters

    • key: Object | Object[]

      The key returned by on() or once() (or an array of keys).

    Returns void

    Function

    Api

    stable

  • Unsets a property.

    Parameters

    • key: string

      Key name.

    • Optional opt_silent: boolean

      Unset without triggering an event.

    Returns void

    Api

    stable

  • Removes an event listener using the key returned by on() or once().

    Parameters

    • key: Object | Object[]

      The key returned by on() or once() (or an array of keys).

    Returns void

    Api

    stable

Generated using TypeDoc