3. Geolocation API
The Geolocation API exposes the latitude and
longitude to JavaScript in a webpage by using
the geolocation object, which is a child object
of the window.navigator.
4. Geolocation API - Method
getCurrentPosition(successCallback,
[errorCallback],
[options])
The function specified by
thesuccessCallback parameter takes
one position parameter.
The function specified by
theerrorCallback parameter takes
one positionError parameter
5. Geolocation API - Geoposition
Position
Properties
Coords
Properties
Explain
coords
latitude The latitude of the location specified in
the coordinates object
longitude The longitude of the location specified in
the coordinates object
altitude Specifies the altitude, in meters, of
the coordinates object.
accuracy Gets the accuracy of the latitude
and longitude properties , in meters.
altitudeAccuracy Accuracy of the altitude property, in meters.
heading Specifies a direction of travel
speed Current ground speed of the device running
Internet Explorer, specified in meters per second.
timestamp Gets the time associated with the geographic information
6. Geolocation API - PositionError
Properties Explain
code Error Code
UNKNOWN_ERROR Uncertainty Error
PERMISSION_DENIED The user has denied permission for the website to access
geographic information.
POSITION_UNAVAILABLE The geographic location could not be determined.
TIMEOUT The request did not complete within the time allowed.
message Gets an error message for debugging purposes.
7. Geolocation API - Option
Properties Explain
enableHighAccuracy bool (false) Obtain the most accurate position possible, or
false to optimize in favor of performance and
power consumption.
timeout Integer (none) An Integer value that indicates the time, in
milliseconds, allowed for obtaining the position.
maximumAge Integer (0) An Integer value indicating the maximum age,
in milliseconds, of cached position information.
8. Geolocation API - Method
watchPosition(successCallback,
[errorCallback],
[options])
Returns :WatchID [Integer]
Begins listening for updates to the current
geographical location of the device running
the client.
9. Geolocation API - Method
clearWatch ( WatchID )
Stops listening for updates to the current
geographical location.