地理定位在React原生项目中不起作用



我使用expo:创建了一个项目

expo init geotest

下一个安装库:

npm install react-native-geolocation-service

在app.json:中添加权限

"android": {
"permissions": [
"ACCESS_FINE_LOCATION"
]
}

App.js包含以下代码:

https://github.com/Agontuk/react-native-geolocation-service/blob/master/example/App.js

但当我调用Geolocation.getCurrentPosition时,我收到一个警告:

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'RNFusedLocation.getCurrentPosition')]

所有的想法都结束了,请帮忙。

我认为您应该使用expo-location并正确阅读文档。这是链接https://docs.expo.io/versions/latest/sdk/location/。如果您在执行此操作时遇到任何问题。那就随便问我吧。谢谢。

最新更新