【发布时间】:2019-09-12 19:30:41
【问题描述】:
我在 Android 上使用 Geolocation 来获取用户的位置。我对 EnableHighAccuracy 设置有点困惑。基本上,要完成这项工作,我必须将其设置为 Android 模拟器的“真”和物理设备的“假”。否则它坏了,我得到超时错误并且没有位置。
有人可以澄清为什么会这样吗?奇怪的是,这个设置在不应该的时候完全破坏了它。我不知道这是否与设备设置或其他有关。这对于生产来说似乎有点危险,因为这太hacky了。谢谢。
navigator.geolocation.getCurrentPosition(
async (locationObj) => {
//Some code
},
(error => Alert.alert("Could not get location"),
{ enableHighAccuracy: true, timeout: 15000 }
)
【问题讨论】:
标签: javascript android react-native geolocation