OpenLayers.Control.Geolocate

The Geolocate control wraps w3c geolocation API into control that can be bound to a map, and generate events on location update

To use this control requires to load the proj4js library if the projection of the map is not EPSG:4326 or EPSG:900913.

Inherits from

Summary
OpenLayers.Control.GeolocateThe Geolocate control wraps w3c geolocation API into control that can be bound to a map, and generate events on location update
Properties
events{OpenLayers.Events} Events instance for listeners and triggering control specific events.
geolocation{Object} The geolocation engine, as a property to be possibly mocked.
available{Boolean} The navigator.geolocation object is available.
bind{Boolean} If true, map center will be set on location update.
watch{Boolean} If true, position will be update regularly.
geolocationOptions{Object} Options to pass to the navigator’s geolocation API.
Constructor
OpenLayers.Control.GeolocateCreate a new control to deal with browser geolocation API
Functions
destroy
activateActivates the control.
deactivateDeactivates the control.
geolocateActivates the control.
getCurrentLocation{Boolean} Returns true if a event will be fired (successfull registration)
failuremethod called on browser’s geolocation failure

Properties

events

{OpenLayers.Events} Events instance for listeners and triggering control specific events.

Register a listener for a particular event with the following syntax

control.events.register(type, obj, listener);

Supported event types (in addition to those from OpenLayers.Control.events)

locationupdatedTriggered when browser return a new position.  Listeners will receive an object with a ‘position’ property which is the browser.geolocation.position native object, as well as a ‘point’ property which is the location transformed in the current map projection.
locationfailedTriggered when geolocation has failed
locationuncapableTriggered when control is activated on a browser which doesn’t support geolocation

geolocation

{Object} The geolocation engine, as a property to be possibly mocked.  This is set lazily to avoid a memory leak in IE9.

available

{Boolean} The navigator.geolocation object is available.

bind

{Boolean} If true, map center will be set on location update.

watch

{Boolean} If true, position will be update regularly.

geolocationOptions

{Object} Options to pass to the navigator’s geolocation API.  See http://dev.w3.org/geo/api/spec-source.html.  No specific option is passed to the geolocation API by default.

Constructor

OpenLayers.Control.Geolocate

Create a new control to deal with browser geolocation API

Functions

destroy

destroy: function()

activate

activate: function ()

Activates the control.

Returns

{Boolean} The control was effectively activated.

deactivate

deactivate: function ()

Deactivates the control.

Returns

{Boolean} The control was effectively deactivated.

geolocate

geolocate: function (position)

Activates the control.

getCurrentLocation

getCurrentLocation: function()

Returns

{Boolean} Returns true if a event will be fired (successfull registration)

failure

failure: function (error)

method called on browser’s geolocation failure

destroy: function()
activate: function ()
Activates the control.
deactivate: function ()
Deactivates the control.
geolocate: function (position)
Activates the control.
getCurrentLocation: function()
{Boolean} Returns true if a event will be fired (successfull registration)
failure: function (error)
method called on browser’s geolocation failure
Controls affect the display or behavior of the map.
{OpenLayers.Events} Events instance for listeners and triggering control specific events.
Close