--------------------------- 测试使用的坐标来源
wx.chooseLocation({
success: res=>{
let userLocal = {};
userLocal.latitude = res.latitude;
userLocal.longitude = res.longitude;
}
});
--------------------------- 微信小程序JavaScript SDK
qqmapsdk.calculateDistance({
from:{
latitude: 23.54786,
longitude: 113.58817
},
to: [{
latitude: 23.516592248000045,
longitude: 113.64378112400001
}],
success: function(res) {//成功后的回调
console.log( 'success',res );
}
})
--------------------------- 腾讯地图javascript api
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=you key&libraries=drawing,geometry,autocomplete,convertor"></script>
<script type="text/javascript">
var gb = new qq.maps.LatLng( 23.54786, 113.58817 );
var jia = new qq.maps.LatLng( 23.516592248000045, 113.64378112400001 );
//初始化地图
var map = new qq.maps.Map(container, {
// 地图的中心地理坐标。
center: gb,
zoom: 12
});
//计算两点间的距离
console.log("接口两点间距离是:" + qq.maps.geometry.spherical.computeDistanceBetween(gb, jia) + "米");
</script>
--------------------------- redis测试
geoadd jvli 113.58817 23.54786 gb 113.64378112400001 23.516592248000045 jia
geodist jvli gb jia
--------------------测试结果
redis 6652.6668米
腾讯地图javascript api: 6658.050米
微信小程序JavaScript SDK: 7304米