更新记录

V1.2(2024-06-05) 下载此版本

1.添加逆地理编码功能 2.优化接口,可配置定位频率

V1.1(2024-05-27) 下载此版本

插件使用说明更新


平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 14.0 armeabi-v7a:未测试,arm64-v8a:未测试,x86:未测试 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


初始化插件

var plugin = uni.requireNativePlugin('long-gnss-location');

plugin.openGps(1000,0);//开启定位,
参数一:位置信息更新周期,单位毫秒;
参数二:位置变化最小距离:当位置距离变化超过此值时,将更新位置信息,单位米

plugin.closeGps();//关闭定位

获取定位数据

var time = plugin.getTimeStr();//2024/05/16 16:25:31

var lat = plugin.getLat()//30.48818333  ,度格式
var lng = plugin.getLng()//114.55732833

var latDu = plugin.getLatDuStr()//30°29'17.45999″N  ,分格式
var lngDu = plugin.getLngDuStr()//114°33'26.38199″E

var gga = plugin.getGGA()
var rmc = plugin.getRMC()

{
"time":时间戳,
"lng":经度,
"NorS":"纬度方向 N-北纬,S-南纬",
"lat":纬度,
"EorW":"经度方向 E/W",
"alt":海拔高,
"count":卫星数量,
"hdop":"水平定位精度,单位米",
"corsDelay":"差分延迟",
"status":"0未定位,1单点解。2伪距差分,4固定解,5浮点解",
"heightDiff":"高程异常值单位:m"
}

{
"isLocation":是否定位,
"heading":"航向",
"speed":"速度,km/h"
"magneticAngle":"磁偏角",
"magneticAngleDir":"磁偏角方向",
} 

获取各系统卫星信息

var bd = plugin.getBDSatellite();//北斗卫星信息
var gps = plugin.getGPSSatellite();//GPS卫星信息
var gln = plugin.getGLNSatellite();//格洛纳斯卫星信息
var gal = plugin.getGALSatellite();//伽利略卫星信息
var qzs = plugin.getQZSSatellite();//天顶卫星信息

{
"navSys":卫星系统("BD", "GPS", "GAL", "GLN", "QZS"),
"prn":卫星PRN码,
"azim":方位角,
"elevation":仰角,
"signFrequency":此时对应的卫星频段,
"snr":信噪比
}

[{"azim":"227","elevation":"57","navSys":"BD","prn":"21","signFrequency":"","snr":"29.2"},{"azim":"188","elevation":"56","navSys":"BD","prn":"03","signFrequency":"","snr":"25.3"},{"azim":"130","elevation":"43","navSys":"BD","prn":"01","signFrequency":"","snr":"22.4"},]

[{"azim":"156","elevation":"51","navSys":"GPS","prn":"50","signFrequency":"","snr":"31.0"},{"azim":"172","elevation":"38","navSys":"GPS","prn":"13","signFrequency":"","snr":"31.3"},{"azim":"091","elevation":"29","navSys":"GPS","prn":"06","signFrequency":"","snr":"26.7"},]

获取Nema原始报文

plugin.getOriginData()//获取最新的一组报文。返回List<String>

[
    "$GNGGA,073306.052,3029.2928,N,11433.4394,E,1,6,1.62,54.0,M,-12.8,M,,*57\r\n",
    "$GNGSA,A,3,05,19,13,12,,,,,,,,,1.90,1.62,0.99,1*00\r\n",
    "$GNGSA,A,3,,,,,,,,,,,,,1.90,1.62,0.99,2*0F\r\n",
    "$GNGSA,A,3,,,,,,,,,,,,,1.90,1.62,0.99,3*0E\r\n",
    "$GNGSA,A,3,12,,,,,,,,,,,,1.90,1.62,0.99,4*0A\r\n",
    "$GNGSA,A,3,02,,,,,,,,,,,,1.90,1.62,0.99,5*0A\r\n",
    "$GPGSV,4,1,13,20,67,324,,11,59,024,,05,51,265,31.9,50,51,156,,1*79\r\n",
    "$GPGSV,4,2,13,06,35,077,,12,26,249,29.5,19,25,145,33.9,13,25,176,30.8,1*70\r\n",
    "$GPGSV,4,3,13,09,18,044,,25,18,278,,29,13,320,,15,07,204,,1*6F\r\n",
    "$GPGSV,4,4,13,17,03,145,,1*53\r\n",
    "$GLGSV,1,1,4,72,77,178,,71,47,034,,65,18,205,,81,04,207,,1*40\r\n",
    "$GBGSV,4,1,15,34,77,004,,21,68,046,,12,61,101,42.5,10,61,224,,1*60\r\n",
    "$GBGSV,4,2,15,08,60,313,,03,55,188,,07,54,195,,13,54,292,,1*78\r\n",
    "$GBGSV,4,3,15,11,53,331,,01,43,130,,02,41,229,,04,31,115,,1*7B\r\n",
    "$GBGSV,4,4,15,14,28,217,,05,21,250,,22,16,040,,1*4B\r\n",
    "$GQGSV,1,1,1,02,17,168,35.0,1*77\r\n",
    "$GNRMC,073306.052,A,3029.2928,N,11433.4394,E,0.015,320.62,220524,,,A,V*39\r\n",
    "$GNVTG,320.62,T,,M,0.015,N,0.027,K,A*27\r\n",
    "$GNACCURACY,2.6,179.9,0.8,79.5*25\r\n"
]

报文实时回调 。 Uni性能不够,建议主动获取


plugin.openOriginDataEvent();//开启

var globalEvent = uni.requireNativePlugin('globalEvent');//注册监听
    globalEvent.addEventListener('nemaEvent', function(e) {
    console.log('nemaEvent' + JSON.stringify(e));
    });

plugin.closeOriginDataEvent();//关闭

经纬度查询地址

注意:需要传入经度,纬度,天地图key;默认key仅供测试使用,有次数限制

plugin.getAddress(116.37304, 39.92594, "", (resultBean) => {
console.log("详细地址-->" + resultBean.formatted_address)
console.log("此点的具体信息-->" + resultBean.addressComponent)
console.log("接口返回的完整json数据-->" + resultBean.json)
});

{
"formatted_address":"北京市西城区什刹海街道西什库大街19号院",
"addressComponent":{
"road_distance":49,
"road":"大红罗厂街",
"address":"西什库大街19号院",
"province":"北京市",
"poi_distance":21,
"province_code":"156110000",
"address_position":"西南",
"city_code":"156110100",
"poi":"西什库大街19号院",
"county":"西城区",
"poi_position":"西南",
"nation":"中国",
"county_code":"156110102",
"address_distance":21,
"city":""
},
"json":"完成的json数据"
}

隐私、权限声明

1. 本插件需要申请的系统权限列表:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

作者未提供license.md

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问