lzf李子凡
lzf李子凡
  • 发布:2023-07-28 17:16
  • 更新:2023-07-30 18:56
  • 阅读:178

uni.getLocation定位总是到固定经纬度

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows11

HBuilderX类型: 正式

HBuilderX版本号: 3.5.3

手机系统: Android

手机系统版本号: Android 11

手机厂商: 小米

手机机型: xiaomi11

页面类型: vue

vue版本: vue2

打包方式: 离线

项目创建方式: HBuilderX

示例代码:

uni.getLocation({
type: 'wgs84',
//geocode: true,
isHighAccuracy: true,
altitude: true,
highAccuracyExpireTime: '8000',
success: (res) => {
console.log("定位获取:", res);
//转换百度地图
// let x = longitude
// let y = latitude
// let x_pi = (3.14159265358979324 3000.0) / 180.0
// let z = Math.sqrt(x
x + y y) + 0.00002 Math.sin(y x_pi)
// let theta = Math.atan2(y, x) + 0.000003
Math.cos(x x_pi)
// let lngs = z
Math.cos(theta) + 0.0065
// let lats = z * Math.sin(theta) + 0.006

                    // lngs = Math.floor(lngs * 1000000) / 1000000;   
                    // lats = Math.floor(lats * 1000000) / 1000000;  
                    this.longitude = res.longitude;  
                    this.latitude = res.latitude;  
                    //this.poiName = res.address.poiName;  
                    console.log('当前位置的经度:' + this.longitude);  
                    console.log('当前位置的纬度:' + this.latitude);  
                    uni.showToast({  
                        title: "当前位置的经度:" + this.longitude +  
                            "\r\n当前位置的纬度:" + this.latitude +  
                            "\r\n当前地址位置:",  
                        icon: 'none',  
                        duration: 3000  
                    })  
                },  
                fail: function(res) {  
                    var titles = JSON.stringify(res);  
                    uni.showToast({  
                        title: titles,  
                        icon: 'none',  
                        duration: 3000  
                    })  

                    console.log(res)  
                    console.log(JSON.stringify(res))  
                },  
                complete: function(res) {  
                    console.log(JSON.stringify(res))  
                }  
            });

操作步骤:

11

预期结果:

走5-10米定位不同的经纬度

实际结果:

相同的经纬度

bug描述:

uni.getLocation定位总是到固定经纬度 uni.getLocation wgs84
自定义基座运行,在uni-app上启动运行到安卓手机上的

1、走几十米一直是相同的经纬度
2、关闭wifi或则流量就定位超时了,这里不是使用gps定位吗

2023-07-28 17:16 负责人:无 分享
已邀请:
喜欢技术的前端

喜欢技术的前端 - QQ---445849201

  • lzf李子凡 (作者)

    用的就是高德地图

    2023-07-31 08:48

5***@qq.com

5***@qq.com

可以在QQ群内咨询 群号:334806568

要回复问题请先登录注册