【问题标题】:Bad/poor GPS location accuracy on Android with React Native使用 React Native 的 Android 上的 GPS 定位精度差/差
【发布时间】: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


【解决方案1】:

我发现问题在于我的AndroidManifest.xml 中没有ACCES_FINE_LOCATION 权限。这有点令人困惑,因为这并没有导致任何实际错误,只是没有给出准确的位置。

所以只需将其添加到清单文件中

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

【讨论】:

    猜你喜欢
    • 2017-09-23
    • 1970-01-01
    • 2017-07-10
    • 2021-11-25
    • 2017-11-24
    • 2013-08-14
    • 2011-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多