JS: getLocationAndPoint() {
uni.getLocation({
type: 'wgs84',
geocode: true, //设置该参数为true可直接获取经纬度及城市信息
success: (res) => {
console.log('经纬度',res.longitude,res.latitude)
this.latitude = res.latitude
this.longitude = res.longitude
},

- 发布:2023-02-03 10:34
- 更新:2023-02-03 17:55
- 阅读:261
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Win11
HBuilderX类型: 正式
HBuilderX版本号: 3.6.15
手机系统: Android
手机系统版本号: Android 12
手机厂商: 小米
手机机型: 红米K50至尊版
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
组件代码:<map id="map" ref="map" :scale="scale" :style="{height: windowHeight}" :markers="covers" :controls="controls"
latitude="latitude" :longitude="longitude" :show-location="true" @markertap="markertap" show-scale
@poitap="poitap" @controltap="controltap" :enable-poi="true"></map>
操作步骤:
使用map组件并设置中心经纬度属性和show-location属性
使用uni.getLocation方法获取当前位置并赋值给中心经纬度绑定的属性
使用map组件并设置中心经纬度属性和show-location属性
使用uni.getLocation方法获取当前位置并赋值给中心经纬度绑定的属性
预期结果:
中心经纬度位置有show-location标志
中心经纬度位置有show-location标志
实际结果:
中心经纬度显示定位位置与show-location标志有偏移几公里,切以中心经纬度为准
中心经纬度显示定位位置与show-location标志有偏移几公里,切以中心经纬度为准
bug描述:
nvue中使用map组件,show-location设置为true,map组件属性中心经纬度设置为uni.getLocation获取并赋值,但是实际上在真机调试以及打包后进入APP中,中心经纬度位置与show-location位置相差几公里
1 个回复
FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866
type改为 gcj02
<map> 组件默认为国测局坐标 gcj02