添加插件(相应的key需要到百度地图开发者平台去申请)
cordova plugin add cordova-plugin-baidumaplocation --variable ANDROID_KEY="<API_KEY_ANDROID>" --variable IOS_KEY="<API_KEY_IOS>"
执行baidumap_location.getCurrentPosition()方法时报错:
{"time":"2018-07-31 18:00:12","locType":162,"locTypeDescription":"NetWork location failed because baidu location service can not decrypt the request query, please check the so file !","latitude":5e-324,"longitude":5e-324,"radius":0,"userIndoorState":-1,"direction":-1}
"NetWork location failed because baidu location service can not decrypt the request query, please check the so file !"这里让我们检查so文件,说明配置出错了。
查阅了百度地图开发文档lbsyun.baidu.com/index.php?t…
这里主要是第三步没有做,其他几步都在安卓环境打包过程中做好了,所以这里要在生成的安卓项目下的build.gradle(android/app/build.gradle这个文件,和libs文件夹同级)中添加一个设置
sourceSets{
main{
jniLibs.srcDir 'libs'
jni.srcDirs = []
}
}
就能在重新build/run之后获取到定位信息了。
网友评论