qqmapsdk.reverseGeocoder 添加了域名但是还是报错 fail url not in domain list ,请求大佬指教
网友回复
壁咚😘壁咚🥰:
const app = getApp(), tools = require('../../utils/util'), QQMapWX = require('../../utils/qqmap-wx-jssdk'),
qqmapsdk = new QQMapWX({
key: 'VDWBZ-FWQWS-IQSOS-6U4T5-NHQ2J-KVBEL'
});
getSite() {
let that = this;
wx.getSetting({
// withSubscriptions: true,
success: (res) => {
if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {
wx.showModal({
title: '请求授权当前位置',
content: '需要获取您的地理位置,请确认授权',
success: (val) => {
if (val.cancel) {
wx.showToast({
title: '拒绝授权',
icon: 'none',
duration: 1000
});
} else if (val.confirm) {
wx.openSetting({
// withSubscriptions: true,
success: (user) => {
if (user.authSetting["scope.userLocation"] == true) {
wx.showToast({
title: '授权成功',
icon: 'success',
duration: 1000
});
//再次授权,调用wx.getLocation的API
that.getLocation();
} else {
wx.showToast({
title: '授权失败',
icon: 'none',
duration: 1000
})
}
}
});
}
}
})
} else if (res.authSetting['scope.userLocation'] == undefined) {
that.location();
}
else {
//调用wx.getLocation的API
that.location();
}
}
});
},
async location() {
const that = this;
try {
await that.getWxLocation()
} catch (error) {
Model({
title: '温馨提示',
tip: '获取权限失败,需要获取您的地理位置才能为您提供更好的服务!是否授权获取地理位置?',
showCancel: true,
confirmText: '前往设置',
cancelText: '取消',
sureCall() {
that.toSetting()
},
cancelCall() { }
})
return
}
},
// 获取位置信息
getWxLocation() {
let that = this;
wx.showLoading({
title: '定位中...',
mask: true,
})
return new Promise((resolve, reject) => {
const _locationChangeFn = (res) => {
console.log('location change', res)
that.getLocal(res.latitude,res.longitude);
wx.hideLoading()
wx.offLocationChange(_locationChangeFn);
}
wx.startLocationUpdate({
success: (res) => {
wx.onLocationChange(_locationChangeFn)
resolve()
},
fail: (err) => {
reject()
}
})
})
},
getLocal(latitude, longitude) {
let that = this, { site, obj } = that.data;
qqmapsdk.reverseGeocoder({
location: {
latitude: latitude,
longitude: longitude
},
success: (res) => {
obj.province = res.result.ad_info.province;
let city = res.result.ad_info.city;
obj.city = res.result.ad_info.city;
obj.street = res.result.ad_info.district;
obj.receivingAddress = res.result.address_component.street_number;
// 保存一下当前定位的位置留着后面重新定位的时候搜索附近地址用
that.setData({
targetAddr: res.result.address_component.street_number,
provice: city
});
wx.showToast({
title: '获取详细位置成功',
duration: 2000,
icon: 'success'
})
that.customizeEvent();
},
fail: function (res) {
wx.showToast({
title: '获取失败',
duration: 2000,
icon: 'none'
})
that.setData({
errorInfo:JSON.stringify(res)
})
},
complete: function (res) {
wx.showToast({
title: res,
duration: 10000,
icon: 'none'
})
}
})
},
Mr.Zhao:
加了没加对,加对了没生效,猜猜猜