1***@163.com
1***@163.com
  • 发布:2023-11-07 11:23
  • 更新:2023-11-07 11:23
  • 阅读:347

【报Bug】uni.getLocation()在山上无法获取实时位置

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 企业版 22H2

HBuilderX类型: 正式

HBuilderX版本号: 3.95

手机系统: Android

手机系统版本号: Android 12

手机厂商: 小米

手机机型: 12 pro

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

手动点击按钮调用uni.getLocation,type为"wgs84",返回的位置依旧存在gcj02的坐标点

uni.getLocation({  
                        type: "wgs84",  
                        isHighAccuracy: true,  
                        altitude: true,  
                        accuracy: "best",  
                        success: (res) => {           
                            console.log(res);         
                            _this.wv.evalJS(`updateLocation(${res.longitude},${res.latitude})`)  
                        }  
                    })

预期结果:

位置更新应该跟随设备的移动一直更新

实际结果:

返回的经纬度没有跟随设备移动

bug描述:

在vue文件的onready中使用位置监听,返回的经纬度有时候是gcj02坐标系,有时候是wgs84坐标系。在公园山上的时候定位无法定位只实时位置,
上传附件zip为实地测试录屏,uniapp开发的和高德地图之间的对比,高德可以跟着移动,uniapp只能定位到山下且不再移动

onReady(){  
            let _this = this;  
            uni.startLocationUpdate({  
              success: ress => {  
                    console.log('开启小程序接收位置消息成功');  
                    uni.onLocationChange(function (res) {  
                        console.log(res);  
                        if(o_x != res.longitude && o_y != res.latitude){  
                            // console.log("o_x", o_x);  
                            let userinfo = uni.getStorageSync("userinfo");  
                            let humanid = JSON.parse(userinfo).HUMANID  
                            let humanname = JSON.parse(userinfo).HUMANNAME  
                            // console.log(humanid + '  纬度:' + res.latitude +'   经度:' + res.longitude);  
                            o_x = res.longitude;  
                            o_y = res.latitude;  
                            _this.wv.evalJS(`updateLocation(${res.longitude},${res.latitude})`)  
                            _this.$run(`insert into ymfz.tbtrace(uuid,humanid,HUMANname,x,y,createtime,loctype) values('${nanoid(32)}',${humanid},'${humanname}',${res.longitude},${res.latitude},now(),0);`).then(res=>{  
                                // console.log(res);  
                            })  
                        }  
                    });  
                },  
              fail: err => console.error('开启小程序接收位置消息失败:', err),  
              complete: msg => console.log('调用开启小程序接收位置消息 API 完成')  
            });  
        }
2023-11-07 11:23 负责人:无 分享
已邀请:

要回复问题请先登录注册