Gizwits 地理围栏工具
iOS注意事项:
- 地理围栏功能起作用前提:用户授予始终使用定位功能的权限;
- 地理围栏最多设置20个。
安装移除
cordova plugin add cordova-gizwits-geofencing(Android添加插件需要传入高德地图的AppKey,添加方法如下:cordova plugin add cordova-gizwits-geofencing --variable AMAP_KEY=your_key --variable GMAP_KEY=your_google_map_key)cordova plugin rm cordova-gizwits-geofencing
接口使用说明
App 使用该插件时,需调用 setServerInfo 方法设置服务器信息。
当发生错误时,error 返回的是错误码。错误码请参照最后的错误码表。
-
设置主题 setThemeInfo
// themeColor: 主题色// navi_bg: 导航栏背景色// titleColor: 标题颜色// title: 标题// right_title: 导航右侧按钮标题cordovapluginsgizGeofencing; -
设置服务器信息 setServerInfo
// url: 服务器地址// token// appKey// type: 表明 appKey 类型, 传入的值为 appId 或 enterpriseId(不传时默认值)// version: 接口版本cordovapluginsgizGeofencing; -
选择或编辑区域 pickRegion
// 区域参数region = "latitude": 22123456 "longitude": 113123456 "radius": 200 "status": "enter/leave" "conditionId": "";// 选择新区域时,传入空的 JSON 对象。cordovapluginsgizGeofencing;// 编辑区域时,传入要编辑的区域cordovapluginsgizGeofencing; -
选择地址 pickAddress
// 地址参数address = "latitude": 22123456 "longitude": 113123456;// 选择新地址时,传入空的 JSON 对象。cordovapluginsgizGeofencing;// 编辑地址时,传入要编辑的地址cordovapluginsgizGeofencing; -
添加区域 addRegion
region = "latitude": 22123456 "longitude": 113123456 "radius": 200 "status": "enter/leave" "conditionId": "";cordovapluginsgizGeofencing; -
移除区域 removeRegion
region = "latitude": 22123456 "longitude": 113123456 "radius": 200 "status": "enter/leave" "conditionId": "";cordovapluginsgizGeofencing; -
移除所有区域 removeAllRegions
cordovapluginsgizGeofencing; -
获取区域列表 getRegionList
cordovapluginsgizGeofencing; -
设置区域列表 setRegionList
region = "latitude": 22123456 "longitude": 113123456 "radius": 200 "status": "enter/leave" "conditionId": "";regionList = region;cordovapluginsgizGeofencing; -
获取位置功能授权状态 getAuthorizationStatus
cordovapluginsgizGeofencing;授权状态值及对应说明:
授权状态值 描述 未授权 Authorization status not determined 位置功能不可用 Authorization status restricted 拒绝授权 Authorization status denied 位置功能总是可用 Authorization status authorized always 位置功能在App运行时可用 Authorization status authorized when in use -
请求总是使用位置信息的权限 requestAlwaysAuthorization
cordovapluginsgizGeofencing; -
获取当前位置 getCurrentLocation
cordovapluginsgizGeofencing; -
解析地址 getAddressInfo
// 位置GPS坐标coordinate = "latitude": 23123456 "longitude": 123123456;cordovapluginsgizGeofencing;// 地址格式 { "FormattedAddressLines": [ "中国广东省广州市天河区沙东街道沙太路陶庄5号" ], "Street": "沙太路陶庄5号", "Thoroughfare": "沙太路陶庄5号", "Name": "沙东轻工业大厦", "City": "广州市", "Country": "中国", "State": "广东省", "SubLocality": "天河区", "CountryCode": "CN" }
坐标转换
- WGS-84:是国际标准,GPS坐标(Google Earth使用、或者GPS模块)
- GCJ-02:中国坐标偏移标准,Google Map、高德、腾讯使用 (火星坐标系)
- BD-09 :百度坐标偏移标准,Baidu Map使用
- transformFromWGSToGCJ: WGS-84 转换为 GCJ-02
- transformFromGCJToWGS: GCJ-02 转换为 WGS-84
- transformFromGCJToBaidu: GCJ-02 转换为 BD-09
- transformFromBaiduToGCJ: BD-09 转换为 GCJ-02
coordinate = "latitude": 23123456 "longitude": 123123456;cordovapluginsgizGeofencing;
错误码
当发生错误时,所有接口都只返回一个错误码。错误码及对应信息如下:
错误码 | 描述 |
---|---|
0 | (保留) |
1 | 取消选择位置 (在选择位置界面按了“返回”键) |
2 | 没有使用定位功能的权限 |
3 | 没有始终允许定位 |
4 | 参数不正确 |
5 | 定位功能受限 |
6 | 位置解析失败 |
7 | 高德地图用户Key不正确或过期 |
8 | 高德地图MD5安全码未通过验证 |
9 | google paly服务不可用 |