安卓手机 微信获取地理位置的权限是询问,小程序就没有获取地理位置的弹框
发布于 5 年前 作者 lei79 3804 次浏览 来自 问答

如题所示

我这边功能是做出来了,IOS没有问题,每次打开小程序,右上角有指南针显示,说明能获取地理位置

但是有些安卓手机,如果微信获取地理位置的权限是询问的话,小程序就没有获取地理位置的弹框

微信获取地理位置的权限是允许的话,就没这个问题

获取地理位置功能在app.js的onShow里面.直接用高德的sdk获取地理位置

代码:

loadLocation: function() {

var that = this;

var myAmapFun = new amap.AMapWX({

key: aMapKey

});

myAmapFun.getRegeo({

success: function(res) {

console.log(res);

// console.log(res[0].regeocodeData.addressComponent.province); //省份

// console.log(res[0].regeocodeData.addressComponent.city); //市

// console.log(res[0].regeocodeData.addressComponent.district); //区

if (res[0].regeocodeData.addressComponent.city[0]) {

that.globalData.positioning = res[0].regeocodeData.addressComponent.province + “-” + res[0].regeocodeData.addressComponent.city + “-” + res[0].regeocodeData.addressComponent.district;

//四个直辖市没有城市值,直接省-区

console.log(that.globalData.positioning);

} else {

that.globalData.positioning = res[0].regeocodeData.addressComponent.province + “-” + res[0].regeocodeData.addressComponent.district;

console.log(that.globalData.positioning);

}

that.globalData.latitudeLongitude = res[0].longitude + “,” + res[0].latitude;

console.log(that.globalData.latitudeLongitude);//经纬度

//埋点:授权弹框允许

},

fail: function(res) {

console.log(res);

if (res.errMsg == “getLocation:fail auth deny”) {

console.log(“地理位置拒绝授权”);

//埋点:授权弹框拒绝

}

}

});

1 回复

你进小程序有用authorize检测定位权限吗??

回到顶部