The nsIDOMGeoGeolocation interface provides access to geolocation information. You can request a single notification of the user's current position, or you can monitor the position over time.
Inherits from: nsISupports
Implemented by: @mozilla.org/geolocation;1. Starting in Gecko 1.9.2, you can access this service using:
var geolocation = Components.classes["@mozilla.org/geolocation;1"]
.getService(Components.interfaces.nsIDOMGeoGeolocation);
Note: if nsIDGeoGeolocation throws an exception when importing, try using this:
var geolocation = Components.classes["@mozilla.org/geolocation;1"]
.getService(Components.interfaces.nsISupports);
void clearWatch(in unsigned short watchId); |
void getCurrentPosition(in nsIDOMGeoPositionCallback successCallback, [optional] in nsIDOMGeoPositionOptions options); |
unsigned short watchPosition(in nsIDOMGeoPositionCallback successCallback, [optional] in nsIDOMGeoPositionOptions options); |
| Attribute | Type | Description |
lastPosition |
nsIDOMGeoPosition |
The most recently retrieved location as seen by the provider. May be null. Read only. |
When the clearWatch() method is called, the watch() process stops calling for new position identifiers and cease invoking callbacks.
void clearWatch( in unsigned short watchId );
None.
Acquires the user's current position via a new position object. If this fails, errorCallback is invoked with an nsIDOMGeoPositionError argument.
void getCurrentPosition( in nsIDOMGeoPositionCallback successCallback, [optional] in nsIDOMGeoPositionErrorCallback errorCallback, [optional] in nsIDOMGeoPositionOptions options );
successCallbacknsIDOMGeoPositionCallback to be called when the current position is available.errorCallback nsIDOMGeoPositionErrorCallback that is called if an error occurs while retrieving the position; this parameter is optional.optionsnsIDOMGeoPositionOptions object specifying options; this parameter is optional.Similar to getCurrentPosition(), except it continues to call the callback with updated position information periodically until clearWatch() is called.
unsigned short watchPosition( in nsIDOMGeoPositionCallback successCallback, [optional] in nsIDOMGeoPositionErrorCallback errorCallback, [optional] in nsIDOMGeoPositionOptions options );
successCallbacknsIDOMGeoPositionCallback that is to be called whenever new position information is available.errorCallback nsIDOMGeoPositionErrorCallback to call when an error occurs; this is an optional parameter.optionsnsIDOMGeoPositionOptions object specifying options; this parameter is optional.An ID number that can be used to reference the watcher in the future when calling clearWatch().