Properties
The Geolocation interface neither implements, nor inherits any property.
MethodsThe Geolocation interface doesn't inherit any method.
Geolocation.getCurrentPosition()
Determines the device's current location and gives back a Position object with the data.
Geolocation.watchPosition()
Returns a long value representing the newly established callback function to be invoked whenever the device location changes.
Geolocation.clearWatch()
Removes the particular handler previously installed using watchPosition().
2. Geolocation Dom API definition in webidl
definition in file gecko/dom/webidl/Geolocation.webidl.
Geolocation API get result of a position from callback function, this is a feature of JavaScript, code as below:
dictionary PositionOptions {
boolean enableHighAccuracy = false;
long timeout = 0x7fffffff;
long maximumAge = 0;
};
[NoInterfaceObject]
interface Geolocation {
[Throws]
void getCurrentPosition(PositionCallback successCallback,
optional PositionErrorCallback? errorCallback = null,
optional PositionOptions options);
[Throws]
long watchPosition(PositionCallback successCallback,
optional PositionErrorCallback? errorCallback = null,
optional PositionOptions options);
void clearWatch(long watchId);
};
callback PositionCallback = void (Position position);
callback PositionErrorCallback = void (PositionError positionError);
3. Geolocation implementation
Design & Architecture
Figure 3-1 describe the architecture of Geolocation WebAPI in a abstract way:
Figure 3-1
As Figure 3-1 show, Geolocation WebAPI work throughout Gaia, Gecko and Gonk, it implement the sandbox feature by the Content process and Chrome process,
it will check the APP permission when Geolocation WebAPI be called. Geolocation feature is bring to implementation in Gonk.