【发布时间】:2020-08-01 11:24:24
【问题描述】:
我使用的是来自“react-native-geolocation-service”库的地理定位,详细信息如下。我的移动应用程序严重依赖位置(地理坐标),因此必须正确获取纬度/经度。我面临的问题是android正在返回缓存的位置。我已经在我的代码中删除了 maximumAge 参数,但我仍然在 android 中获取缓存的 lat long。有没有一种方法可以让我始终从 android 中的 GPS 获取当前位置,以使用这个库做出反应?任何帮助表示赞赏。谢谢。
AndoidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Location.js:
import Geolocation from 'react-native-geolocation-service';
getCoordinates = () => {
Geolocation.getCurrentPosition(
position => {
this.setState({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
});
},
error => {
}, { enableHighAccuracy: true, timeout: 15000 },
)
};
【问题讨论】:
标签: android react-native geolocation