request合法域名配置了 https://apis.map.qq.com ,在微信开发者工具上可以通过经纬度使用qqmapsdk.reverseGeocoder()获取到位置信息,在手机上打开调试模式也可以,但是一关调试模式就不行了。。。。卡了一天多了,求大哥支援。。。。。小弟感激不尽。。。。。
js代码如下:
var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');
var qqmapsdk;
var that=this;
onLoad: function (options) {
// 实例化API核心类
qqmapsdk = new QQMapWX({
key: 'EZHBZ-IYE3J-N2EFI-FNGZ6-IWTYS-56BCU'
})
},
getNowPoint:function(){
var that = this;
wx.getLocation({
type: 'wgs84', //返回可以用于wx.openLocation的经纬度
success: function (res) {
var latitude = res.latitude//维度
var longitude = res.longitude//经度
//console.log(res);
//that.loadCity(latitude, longitude);
qqmapsdk.reverseGeocoder({
location: {
latitude: latitude,
longitude: longitude
},
success: function (res) {
//在手机运行,如果不开调试模式,不进这个方法
},
fail: function (res) {
},
complete: function (res) {
that.mapCtx.moveToLocation();
that.setData({
Position: res.result.address,
latitude: latitude,
longitude: longitude
})
wx.showToast({
title: "成功",
icon: 'success',
duration: 2000
})
}
});
}
})
}
你在这里面把res 打印出来呢。应该是报错了。
怎么打印。。。在模拟器上运行正常,打印出来的都是正常数据 数据如下:
{"status":0,"message":"query ok","request_id":"97bc712e-dcf4-11e8-8fcd-6c92bf1a7ce7","result":{"location":{"lat":39.5228,"lng":116.71051},"address":"河北省廊坊市广阳区康宁街2号","formatted_addresses":{"recommend":"明珠美食城廊坊市广阳区委(康宁道北)","rough":"明珠美食城廊坊市广阳区委(康宁道北)"},"address_component":{"nation":"中国","province":"河北省","city":"廊坊市","district":"广阳区","street":"康宁街","street_number":"康宁街2号"},"ad_info":{"nation_code":"156","adcode":"131003","city_code":"156131000","name":"中国,河北省,廊坊市,广阳区","location":{"lat":39.5228,"lng":116.71051},"nation":"中国","province":"河北省","city":"廊坊市","district":"广阳区"},"address_reference":{"business_area":{"id":"8372727736878567988","title":"明珠美食城","location":{"lat":39.5228,"lng":116.71051},"_distance":0,"_dir_desc":"内"},"famous_area":{"id":"8372727736878567988","title":"明珠美食城","location":{"lat":39.5228,"lng":116.71051},"_distance":0,"_dir_desc":"内"},"crossroad":{"id":"2257842","title":"新华路/康宁道(路口)","location":{"lat":39.522442,"lng":116.708138},"_distance":202.1,"_dir_desc":"东"},"town":{"id":"131003003","title":"解放道街道","location":{"lat":39.5228,"lng":116.71051},"_distance":0,"_dir_desc":"内"},"street_number":{"id":"7256170021335005277","title":"康宁街2号","location":{"lat":39.5228,"lng":116.71051},"_distance":0,"_dir_desc":""},"street":{"id":"9064187769210129302","title":"康宁道","location":{"lat":39.522659,"lng":116.710533},"_distance":10.2,"_dir_desc":"北"},"landmark_l2":{"id":"11121266031923787995","title":"廊坊市广阳区委","location":{"lat":39.5228,"lng":116.71051},"_distance":0,"_dir_desc":""}}}}
在手机上开调试模式运行也是正常的,调试模式关了就GG了。。。怎么打印出来错误信息。。。。。
用那个真机测试,然后看有没有进fail呢?
没有,直接进 complete
刚才官方给我回复不支持了,应该是小程序隐私之类的问题不支持了,直接从后台调吧
你好,暂不支持把 https://apis.map.qq.com添加为域名。
以前可以加的
会不会和地图部门吵起来呢?
安全域名没加
大哥,安全域名是哪一个。。。。我才第三天接触小程序,不太懂。。。。。我的配置是这样子的。。。。
不知道官方为啥回复不支持,我之前做地图就是这么搞得,可能有什么新规定吧。一般需要开调试的问题都是检查域名配置就好了
那我用wx.request调后台,然后在后台调地址逆解析应该就可以实现吧?
是的
OK,了解了,谢谢大哥