- 发布:2020-08-17 09:30
- 更新:2021-01-26 10:48
- 阅读:1820
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 2.8.3
手机系统: 全部
手机厂商: 华为
页面类型: vue
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
操作步骤:
_self.amapPlugin = new amap.AMapWX({
key: "9*****6" //该key 是在高德中申请的微信小程序key
});
_self.amapPlugin.getRegeo({
success: (res) => {
console.log(res);//可自己查看所需返回值取用
_self.address = res[0].regeocodeData.formatted_address;
_self.lat = res[0].latitude; //纬度
_self.lng = res[0].longitude; //经度
/ uni.showModal({
title:"坐标",
content:"经纬度:["+ _self.lat+","+_self.lng+"]"
}) /
console.log("经纬度:["+ _self.lat+","+_self.lng+"]");
},
fail:(data)=>{
console.log(data)
}
});
_self.amapPlugin = new amap.AMapWX({
key: "9*****6" //该key 是在高德中申请的微信小程序key
});
_self.amapPlugin.getRegeo({
success: (res) => {
console.log(res);//可自己查看所需返回值取用
_self.address = res[0].regeocodeData.formatted_address;
_self.lat = res[0].latitude; //纬度
_self.lng = res[0].longitude; //经度
/ uni.showModal({
title:"坐标",
content:"经纬度:["+ _self.lat+","+_self.lng+"]"
}) /
console.log("经纬度:["+ _self.lat+","+_self.lng+"]");
},
fail:(data)=>{
console.log(data)
}
});
预期结果:
"经纬度:["+ _self.lat+","+_self.lng+"]"
"经纬度:["+ _self.lat+","+_self.lng+"]"
实际结果:
{
"errCode": "0",
"errMsg": "getLocation:fail [geolocation:7]KEY错误 请到http://lbs.amap.com/api/android-location-sdk/guide/utilities/errorcode/查看错误码说明,错误详细信息:auth fail:INVALID_USER_SCODE#SHA1AndPackage#2****p#gsid#"
}
{
"errCode": "0",
"errMsg": "getLocation:fail [geolocation:7]KEY错误 请到http://lbs.amap.com/api/android-location-sdk/guide/utilities/errorcode/查看错误码说明,错误详细信息:auth fail:INVALID_USER_SCODE#SHA1AndPackage#2****p#gsid#"
}
bug描述:
使用高德地图定位的问题,打基座前可以,打基座后就一直报错,说key鉴权错误,换到标准基座可以,我同事的没有打基座也可以,我打基座也是云端打的,正式打包成app也不行
2 个回复
sharkcheung
看下你在高德地图设置的sha1值是否是正确的
穷鬼溪风 - 程序猿
解决了吗?我也遇到同样的问题