new Geolocation
Helper class for providing HTML5 Geolocation capabilities. The Geolocation API is used to locate a user's position.
Example:
var geolocation = new ol.Geolocation();
// take the projection to use from the map's view
geolocation.bindTo('projection', map.getView());
// listen to changes in position
geolocation.on('change:position', function(evt) {
window.console.log(geolocation.getPosition());
});
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
options |
ol.GeolocationOptions |
<optional> |
(Optional) Options. |
- Source:
- geolocation.js, line 52
Extends
Members
-
<static, constant> SUPPORTED :boolean
-
Is HTML5 geolocation supported in the current browser?
- Source:
- geolocation.js, line 146
Methods
-
bindTo
-
Binds a View to a Model.
Parameters:
Name Type Argument Description keystring Key.
targetol.Object Target.
targetKeystring <optional>
(Optional) Target key.
noNotifyboolean <optional>
(Optional) No notify.
- Inherited From:
- Source:
- object.js, line 147
-
get
-
Gets a value.
Parameters:
Name Type Description keystring Key.
- Inherited From:
- Source:
- object.js, line 170
Returns:
Value.
- Type
- *
-
getAccuracy
-
Get the accuracy of the position in meters.
- Source:
- geolocation.js, line 189
Returns:
accuracy in meters.
- Type
- number | undefined
-
getAltitude
-
Get the altitude associated with the position.
- Source:
- geolocation.js, line 203
Returns:
The altitude in meters above the mean sea level.
- Type
- number | undefined
-
getAltitudeAccuracy
-
Get the altitude accuracy of the position.
- Source:
- geolocation.js, line 217
Returns:
Altitude accuracy.
- Type
- number | undefined
-
getHeading
-
Get the heading as radians clockwise from North.
- Source:
- geolocation.js, line 231
Returns:
Heading.
- Type
- number | undefined
-
getPosition
-
Get the position of the device.
- Source:
- geolocation.js, line 245
Returns:
position.
- Type
- ol.Coordinate | undefined
-
getProjection
-
Get the projection associated with the position.
- Source:
- geolocation.js, line 259
Returns:
projection.
- Type
- ol.Projection | undefined
-
getSpeed
-
Get the speed in meters per second.
- Source:
- geolocation.js, line 273
Returns:
Speed.
- Type
- number | undefined
-
getTracking
-
Are we tracking the user's position?
- Source:
- geolocation.js, line 287
Returns:
tracking.
- Type
- boolean
-
getTrackingOptions
-
Get the tracking options.
- Source:
- geolocation.js, line 303
- See:
Returns:
HTML 5 Gelocation tracking options.
- Type
- GeolocationPositionOptions | undefined
-
notify
-
Notify all observers of a change on this property. This notifies both objects that are bound to the object's property as well as the object that it is bound to.
Parameters:
Name Type Description keystring Key.
- Inherited From:
- Source:
- object.js, line 208
-
on
-
Listen for a certain type of event.
Parameters:
Name Type Argument Description typestring | Array.<string> The event type or array of event types.
listenerFunction The listener function.
scopeObject <optional>
(Optional) Object is whose scope to call the listener.
- Inherited From:
- Source:
- object.js, line 240
Returns:
Unique key for the listener.
- Type
- goog.events.Key
-
once
-
Listen once for a certain type of event.
Parameters:
Name Type Argument Description typestring | Array.<string> The event type or array of event types.
listenerFunction The listener function.
scopeObject <optional>
(Optional) Object is whose scope to call the listener.
- Inherited From:
- Source:
- object.js, line 253
Returns:
Unique key for the listener.
- Type
- goog.events.Key
-
set
-
Sets a value.
Parameters:
Name Type Description keystring Key.
value* Value.
- Inherited From:
- Source:
- object.js, line 263
-
setProjection
-
Set the projection to use for transforming the coordinates.
Parameters:
Name Type Description projectionol.Projection Projection.
- Source:
- geolocation.js, line 317
-
setTracking
-
Enable/disable tracking.
Parameters:
Name Type Description trackingboolean Enable or disable tracking.
- Source:
- geolocation.js, line 330
-
setTrackingOptions
-
Set the tracking options.
Parameters:
Name Type Description optionsGeolocationPositionOptions HTML 5 Geolocation tracking options.
- Source:
- geolocation.js, line 345
- See:
-
setValues
-
Sets a collection of key-value pairs.
Parameters:
Name Type Description valuesObject.<string, *> Values.
- Inherited From:
- Source:
- object.js, line 286
-
un
-
Unlisten for a certain type of event.
Parameters:
Name Type Argument Description typestring | Array.<string> The event type or array of event types.
listenerFunction The listener function.
scopeObject <optional>
(Optional) Object is whose scope to call the listener.
- Inherited From:
- Source:
- object.js, line 326
-
unbind
-
Removes a binding. Unbinding will set the unbound property to the current value. The object will not be notified, as the value has not changed.
Parameters:
Name Type Description keystring Key.
- Inherited From:
- Source:
- object.js, line 305
-
unbindAll
-
Removes all bindings.
- Inherited From:
- Source:
- object.js, line 344
-
unByKey
-
Removes an event listener which was added with listen() by the key returned by on().
Parameters:
Name Type Argument Description keynumber <nullable>
Key.
- Inherited From:
- Source:
- object.js, line 336