【发布时间】:2021-11-12 11:00:48
【问题描述】:
我正在开发一个适用于 Android 和 iPhone 的 React Native 应用程序。我有一个功能,您可以“分享我当前的位置”。这在 iPhone 上运行良好且准确,但在 Android 上,它只显示正确的城市/地区,但实际位置离您的街道很远。为了获取位置,我使用https://github.com/Agontuk/react-native-geolocation-service 库。
这是相关代码,我只是调用Geolocation.getCurrentPosition,没有做任何特别的事情。我要求选项的准确性很高。关于如何提高 Android 上的准确性的任何想法?
编辑:如果我在同一部 Android 手机上打开 Google 地图,我会得到准确/正确的位置。
Geolocation.getCurrentPosition(
(position) => {
// Do stuff with the position
},
(error) => {
// See error code charts below.
logError(
new Error(
`Cannot get current location: ${error.code} ${error.message}`,
),
);
},
{
enableHighAccuracy: true,
accuracy: {
android: 'high',
ios: 'bestForNavigation',
},
timeout: 15000,
maximumAge: 10000,
distanceFilter: 10,
},
);
}
},```
【问题讨论】:
-
谷歌地图或类似应用程序是否同时显示准确的位置?
-
@Hariks 是的,在谷歌地图上我得到了正确的位置
标签: android react-native geolocation