收藏
回答

qqmapsdk.reverseGeocoder 报错? fail url not in domai

qqmapsdk.reverseGeocoder 添加了域名但是还是报错 fail url not in domain list ,请求大佬指教

回答关注问题邀请回答
收藏

2 个回答

  • 鹊起
    鹊起
    2023-09-15

    引入了qqmap-wx-jssdk.js为什么会说这个不是方法

    2023-09-15
    有用
    回复
  • 哈尔的移动城堡
    哈尔的移动城堡
    2022-04-12
    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',
                      duration1000
                    });
    
    
                  } else if (val.confirm) {
                    wx.openSetting({
                      // withSubscriptions: true,
                      success(user) => {
                        if (user.authSetting["scope.userLocation"] == true) {
                          wx.showToast({
                            title'授权成功',
                            icon'success',
                            duration1000
                          });
                          //再次授权,调用wx.getLocation的API
    
    
                          that.getLocation();
                        } else {
                          wx.showToast({
                            title'授权失败',
                            icon'none',
                            duration1000
                          })
                        }
                      }
                    });
    
    
                  }
                }
              })
            } 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'获取权限失败,需要获取您的地理位置才能为您提供更好的服务!是否授权获取地理位置?',
            showCanceltrue,
            confirmText'前往设置',
            cancelText'取消',
            sureCall() {
              that.toSetting()
            },
            cancelCall() { }
          })
          return
        }
      },
      // 获取位置信息
      getWxLocation() {
        let that = this;
        wx.showLoading({
          title'定位中...',
          masktrue,
        })
        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'获取详细位置成功',
              duration2000,
              icon'success'
            })
            that.customizeEvent();
          },
          failfunction (res{
            wx.showToast({
              title'获取失败',
              duration2000,
              icon'none'
            })
            that.setData({
              errorInfo:JSON.stringify(res)
            })
          },
          completefunction (res{
            wx.showToast({
              title: res,
              duration10000,
              icon'none'
            })
          }
        })
      },
    
    2022-04-12
    有用
    回复
登录 后发表内容