// 重新定位
repositionFun: function () {
let that = this;
wx.getLocation({
type: "gcj02",
altitude: "true",
success: function (res) {
console.log(res);
that.setData({
longitude: res.longitude,
latitude: res.latitude,
scale: 17
});
},
fail: function () {
wx.getSetting({
success: (res) => {
if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {
wx.showModal({
title: '是否授权当前位置',
content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
success: function (res) {
if (res.cancel) {
console.info("1授权失败返回数据");
} else if (res.confirm) {
wx.openSetting({
success: function (data) {
if (data.authSetting["scope.userLocation"] == true) {
wx.showToast({
title: '授权成功',
icon: 'success',
duration: 5000
})
} else {
wx.showToast({
title: '授权失败',
image: "../../images/warn.png",
duration: 2000
});
}
}
})
}
}
})
}
}
});
}
})
},