HTML and CSS Reference
In-Depth Information
B.2. Other APIs and specifications
In this section, we cover the Geolocation API and the IndexedDB specification.
B.2.1. Geolocation API
The Geolocation API methods are defined on the win-
dow.navigator.geolocation object. The options argument in the two position-
retrieval API methods in table B.17 is a Position Options object and can have any
of the attributes defined in table B.18 .
Table B.17. Geolocation API
Attribute/method
Description
Gets the current position of the device, invoking the relev-
ant success callback function when it has been located. If a
problem is encountered, the error callback function will be
called.
getCurrentPosition(successCallback, [errorCallback], [op-
tions])
Monitors the position of the device and invokes the relev-
ant success callback provided as the location of the device
is updated or the error callback if there's a problem. Calling
this function returns a watch ID, which can be passed to
clearWatch to cancel a watch.
watchPosition(successCallback, [errorCallback], [options])
clearWatch(watchId)
Clears an existing geolocation watch.
Table B.18. Position Options object
Attribute/method
Description
Informs the browser that the application would like to receive the maximum possible res-
ults. The browser can use this to determine whether it should use a more accurate sensor
such as a Global Positioning System (GPS) sensor.
enableHighAccuracy
The maximum length of time (in milliseconds) allowed to pass before the relevant call-
back function is invoked.
timeout
Typically, a device will store position information for a period of time to avoid wasting
battery by having the position-detection hardware running constantly. If you're willing to
accept slightly out-of-date position data, you can specify an acceptable maximum age in
milliseconds in this parameter. If the value is 0 or omitted, the browser must fetch a new
position, even if a cached position is available.
maximumAge
When one of the Geolocation API methods invokes a success callback function, it passes a
Position object to that function; see table B.19 .
 
 
Search WWH ::




Custom Search