当前位置: 代码迷 >> 综合 >> 微信小程序定位不精准
  详细解决方案

微信小程序定位不精准

热度:40   发布时间:2024-03-08 22:19:54.0

开始用的wgs84,偏差很明显,在设置了isHighAccuracy: true以后定位依然有很大的偏差,wgs84(是全球定位系统,获取的坐标,gcj02是国家测绘局给出的坐标)

wx.getLocation({

type: 'wgs84',  //坐标系

isHighAccuracy: true,  //提高精确度

success: function(res) {

that.setData({

latitude: res.latitude,

longitude: res.longitude,

})},

fail: function(res) {},

complete: function(res) {},})

后来改成gcj02,效果显著提升,虽然精准度还是不够,但是比wgs84强了很多。

//请求地理位置

requestLocation: function() {

var that = this;

wx.getLocation({

type: 'gcj02',

isHighAccuracy: true,

success: function(res) {

that.setData({

latitude: res.latitude,

longitude: res.longitude,

})

that.regeocodingAddress();

},

fail: function(res) {},

complete: function(res) {},

})},

遇到使用wgs84定位不标准的,不妨试试gcj02。

  相关解决方案