手机不开wifi,只开移动数据的情况下,调用wx.getLocation获取定位信息失败,如何处理?

小程序 文章 2021-01-28 09:21 1361 0 全屏看文

AI助手支持GPT4.0

手机不开wifi,只开移动数据的情况下,调用wx.getLocation获取定位信息失败,如何处理?What should I do if calling wx.getLocation to obtain location information fails when the phone does not open wifi but only uses mobile data?

手机不开wifi,只开移动数据的情况下,调用wx.getLocation获取定位信息失败,如何处理?

我们的小程序是租车业务,用户在租车时需要获取用户借车的实时精确定位,通过手动输入位置的方式会和用户实际定位产生比较大的偏差。实际场景中,用户在外用车都是连移动数据,但是这种情况下调用wx.getLocation获取定位信息是获取不到的,为什么微信API一直没有兼容在移动数据下获取定位的问题?作为小程序开发者,应该怎么处理这种问题?

Our small program is car rental business, users need to get the real-time accurate positioning of the user's car when they rent a car, and there will be a big deviation between the manual input of the location and the user's actual positioning. In the actual scene, the user uses the mobile data in the external vehicle, but in this case, the user calls the mobile data wx.getLocation It is impossible to obtain location information. Why has wechat API not been compatible with the problem of obtaining location under mobile data? As a small program developer, how to deal with this problem?

回答:

brave:

调用wx.getLocation获取定位信息失败 跟网络是wifi和移动数据有啥关系?无非就是要么信号差网络太差,要么就是小程序拒绝位置信息授权,或者就是小程序授权了,手机没有开启位置信息定位的开关。

Ps: 别人开移动数据定位也都正常,不要甩锅给微信。

Misa:移动数据5G情况下
何小强:

如果是5G手机,就算打开手机GPS定位,打开小程序位置授权同样会出现定位失败的情况。

但是只要切换成4G网络就可以获取定位信息。

希望官方能重视一下,能不能对5G手机做一下适配,大部分机型都是华为手机。

Misa:对的,我的也是5G,OPPO的,不开wifi就一直会出现定位失败的情况,调用API会报
“errCode: 2 ,errMsg: getLocation:fail:ERROR_NOCELL&WIFI_LOCATIONSWITCHOFF”,用户在户外,还要求用户打开wifi开关,这样不是太好。
小黎:

怎么可能没有兼容在移动数据下获取定位的问题,你的意思是开wifi就可以?亮代码看看

-EOF-

AI助手支持GPT4.0