React 本机地理定位不适用于设备
React native geolication don't work on device
我尝试在我的应用程序中使用 React-native-geolocation (来自 react-native-community/react-native-geolocation),React Native 0.60.5
.
但是,那行不通。我尝试了很多东西,在网上做了研究,但没有结果。在模拟器上,没有问题。但是在任何设备上,我都没有结果。
有人在用这个包吗?还是换一个?
非常感谢
(抱歉我的英语不好)
我是这样用的:
Geolocation.getCurrentPosition(
({coords: {latitude, longitude}}) => {
this.setState({
region: {
latitude: latitude,
longitude: longitude,
latitudeDelta: 0.0143,
longitudeDelta: 0.0134,
},
});
},
error => {
console.log('Error:', error);
},
{
enableHighAccuracy: true,
},
);
我在文件 AndroidManifest.xml 中添加了这个设置:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
我尝试在我的应用程序中使用 React-native-geolocation (来自 react-native-community/react-native-geolocation),React Native 0.60.5
.
但是,那行不通。我尝试了很多东西,在网上做了研究,但没有结果。在模拟器上,没有问题。但是在任何设备上,我都没有结果。
有人在用这个包吗?还是换一个? 非常感谢 (抱歉我的英语不好)
我是这样用的:
Geolocation.getCurrentPosition(
({coords: {latitude, longitude}}) => {
this.setState({
region: {
latitude: latitude,
longitude: longitude,
latitudeDelta: 0.0143,
longitudeDelta: 0.0134,
},
});
},
error => {
console.log('Error:', error);
},
{
enableHighAccuracy: true,
},
);
我在文件 AndroidManifest.xml 中添加了这个设置:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>