Geolocation WebAPI

1. Geolocation Web API

Properties

The Geolocation interface neither implements, nor inherits any property.

Methods
The 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.














  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值