uni-app中uni.getLocation定位坐标系
uni-app中uni.getLocation定位坐标系
1 回复
更多关于uni-app中uni.getLocation定位坐标系的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在uni-app中,uni.getLocation方法默认返回的坐标系是WGS-84(GPS坐标系)。这是全球通用的经纬度标准,也是大多数定位服务的原始数据格式。
如果你需要在中国大陆地图(如高德、百度地图)上显示,通常需要转换为对应的地图坐标系:
- 高德地图:需要转换为GCJ-02(火星坐标系)
- 百度地图:需要转换为BD-09(百度坐标系)
转换方式:
- 使用地图服务商提供的JS SDK进行转换
- 使用第三方坐标转换库
- 在
uni.getLocation的type参数中指定坐标系(部分平台支持)
示例代码:
uni.getLocation({
type: 'wgs84', // 默认值,可指定为'gcj02'
success: function (res) {
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
}
});

