小程序体验版--打开调试位置调取成功,关闭vconsole调取地图失败
发布于 5 年前 作者 wei80 1775 次浏览 来自 问答

小程序体验版,打开位置按钮

wx.request({
     url: 'https://apis.map.qq.com/ws/geocoder/v1/?address=' + that.data.merAddress + '&key=K3GBZ-54X6Q-QWP5F-GPYT3-57EK3-LVFVV',
     method: 'GET',
     // header: {},
     success: function (res) {
       if (res.data.status == 0) {
         // success
         console.log("请求位置成功");
      
         that.setData({
           lng: res.data.result.location.lng,
           lat: res.data.result.location.lat
         });
         wx.openLocation({
           latitude: res.data.result.location.lat,
           longitude: res.data.result.location.lng,
           scale: 18,
           name: that.data.merchantStore.merStoreName,
           address: that.data.merchantStore.merAddress
         })
       }
     },
     fail: function () {
       // fail
       console.log("请求位置");
     }

打开调试vConsole可以调取内置地图查看位置,但是关闭vConsole调取失败,打开地图失败

1 回复

http://apis.map.qq.com 加入安全域名。

弄了个片段试了下没问题,你删除回复我也回复不了就在这里修改了。

https://developers.weixin.qq.com/s/Xr0qvmmk7y7l

回到顶部