收藏
回答

wx.getLocation 不准确

wx.getLocation返回的经度和维度不准确,怎么处理?

wx.getLocation({
      type: 'gcj02',
      success: function (res) {
        console.log("当前坐标:" + res.latitude + "/" + res.longitude);  
      },
      fail: function(){
        console.log("坐标定位失败")
      },
      complete: function(){
        console.log("坐标定位完成")
      }
    })
  },

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

11 个回答

  • Eric
    Eric
    2017-06-30

    了解了,但是还是不太理解。this代表了什么对象?为什么把this复制给that,that就能代表this对象?

    2017-06-30
    有用
    回复
  • 赵青山
    赵青山
    2017-06-30

    this代表的不是page对象,在外层var that = this,用that

    2017-06-30
    有用
    回复
  • Eric
    Eric
    2017-06-29

    wx.getLocation({
          type: 'gcj02',
          success: function (res) {
            console.log("当前坐标:" + res.latitude + "/" + res.longitude);   
            this.setData({
              longitude: 122.473701,
              latitude: 32.230416,
            })
          },
          fail: function(){
            console.log("坐标定位失败")
          },
          complete: function(){
            console.log("坐标定位完成")
          }
        })

    这样子后台会报错,说setData不是一个function,这是为什么?

    2017-06-29
    有用
    回复
  • Eric
    Eric
    2017-06-29

    怎么赋值给中心点?我现在想要的效果就是把当前位置作为地图的中心点。

    我现在把后台打印出来的经度和维度赋值给下面两个参数

    longitude="{{longitude}}"

    latitude="{{latitude}}"

    但是位置还是不准确。

    2017-06-29
    有用
    回复
  • 赵青山
    赵青山
    2017-06-29

    你再仔细看看,我用4G是准确的,type为gcj02,还有,看坐标数据没用,那是火星坐标,最好设置获取位置后赋值给map中心点

    2017-06-29
    有用
    回复
  • Eric
    Eric
    2017-06-29

    <map id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="{{scale}}" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" show-location style="width: 100%; height: 300pt;"></map>


    show-location 是表示会再地图上显示一个当前位置指向的图标?

    我在手机上跑是可以在定位准确。但是,我从后台拿到的数据放到markers里面,位置就不一样了。不知道什么情况

    2017-06-29
    有用
    回复
  • Eric
    Eric
    2017-06-29

    后台返回的数据就是代码里写的,打印出来的

    console.log("当前坐标:" + res.latitude + "/" + res.longitude); 

    2017-06-29
    有用
    回复
  • Eric
    Eric
    2017-06-29

    是不准确的,但是在一个区的偏差范围内。4g和wifi都试过了,还是不准备的。

    2017-06-29
    有用
    回复
  • 赵青山
    赵青山
    2017-06-29

    map组件使用的经纬度是火星坐标系,你确定你后台返回的数据正确?调用 wx.getLocation 接口需要指定 type 为 gcj02用移动网络定位,wifi定位不准

    2017-06-29
    有用
    回复
  • Eric
    Eric
    2017-06-29

    从后台拿到经度和维度,让后在map中设置经度和维度,结果定位到的地点不是现在所在地。

    2017-06-29
    有用
    回复

正在加载...

登录 后发表内容