南月星儿
南月星儿
  • 发布:2023-05-16 12:38
  • 更新:2024-04-28 09:45
  • 阅读:356

uniapp getLocation:fail translate geo fail

分类:uni-app

通过 uni.getLocation获取用户的定位经纬度信息,但是会提示 getLocation:fail translate geo fail, 有些设备又是正常的,能马上获取到经纬度,请问这个怎么解决呢?

                    uni.getLocation({  
            type: 'gcj02', //gcj02 , wgs84  
            success: function(r) {  
                console.log('当前位置的经度:' + r.longitude);  
                console.log('当前位置的纬度:' + r.latitude);  
            },  
            fail(err) {  
                console.log('err :>> ', err);  

                console.log('获取位置错误');  
                console.log(err);  

                if (  
                  err.errMsg ===  
                  'getLocation:fail 频繁调用会增加电量损耗,可考虑使用 wx.onLocationChange 监听地理位置变化'  
                ) {  
                      uni.showToast({  
                        title: '请勿频繁定位',  
                        icon: 'none'  
                      })  
                }else if (err.errMsg === 'getLocation:fail auth deny') {  
                    // 未授权  
                    uni.showToast({ title: '无法定位,请重新获取位置信息', icon: 'none' })  

                }else if (err.errMsg === 'getLocation:fail:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF') {  

                    uni.showModal({  
                        content: '请开启手机定位服务',  
                        showCancel: false  
                    })  

                }else{  
                    uni.showModal({  
                        content: err.errMsg,  
                        showCancel: false  
                    })  
                }  

            }  

        });
2023-05-16 12:38 负责人:无 分享
已邀请:
瑞芝康健

瑞芝康健

请教这个问题该如何解决

要回复问题请先登录注册