hello h5+通过
plus.geolocation.getCurrentPosition(function(p){
console.log(p)
}, function(e){
alert('Geolocation error: ' + e.message);
} );
此方法获取到的坐标为gcj02 国测局坐标(火星坐标,比如高德地图在用),5+在用此定位的坐标点计算距离时要比实际距离多1km左右;而5+计算面积的方法只有百度地图支持,所以我推测5+获取到定位的坐标应该需要转换为百度坐标然后再进行距离计算【事实证明的确如此】,但是5+的文档计算距离的方法上却没有说明
plus.maps.Map.geocode(place,{city:"深圳"},function(event){
console.log(event.coordType);
},function(e){
alert("Failed:"+JSON.stringify(e));
});
坐标转换方法:http://cnodejs.org/topic/564c0a27e4766d487f6fe38d

vue安装:
(1)npm install coordtransform
(2)组件局部引入 import coordtransformfrom 'coordtransform';
(3)使用 【具体可参考上述链接】:例:coordtransform.gcj02tobd09()

github:【index.js】https://github.com/wandergis/coordtransform
距离计算:


通过逆地理编码(地址)获取坐标,监听坐标值的改变,获取到后再通过坐标获取相距的距离
网友评论