android - 反应原生:反应原生地理定位
问题描述
我需要在 react-native 中获取位置。我用过@react-native-community/geolocation
。当getCurrentPosition
我们有选项时enableHighAccuracy
。
我的问题是当我在其中运行我的应用程序时,android emulator
它必须更改为enableHighAccuracy: true
.
但是当我运行它时device
它不起作用并且必须更改为enableHighAccuracy : false
这是我的代码示例:
const callLocation = () => {
setLoading(true);
Geolocation.getCurrentPosition(position => {
const { longitude, latitude } = position.coords
setLoading(false);
setRegion({ ...region, latitude, longitude });
},
error => console.log(error.message),
{
timeout: 20000,
enableHighAccuracy: true, // must change to false when run on device
maximumAge: 1000 },
);
}
也许你和我有同样的问题,我非常感谢你的帮助。
解决方案
推荐阅读
- java - Java Swing 嵌套 JTable
- c#-4.0 - 转发或回复邮件时获取父邮件项以读取标题
- amazon-web-services - systemctl daemon-reload 失败,参数数量无效
- reactjs - 此路由不支持 POST 方法。支持的方法:GET、HEAD。在 laravel api资源中
- python-3.x - 在某个时间点计算数据框中的灾难
- r - R:用相应但已更改的变量名称替换 for 循环中的 NA
- r - qnorm 的数值问题
- php - Laravel 旧输入 8.x
- python - python 格式的 flake8 (E902) TokenError
- javascript - 如何影响不属于
?