我将在本机反应中获取当前位置。
我使用了下面的代码:
if(Platform.OS == "android") {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
'title': 'Location Permission',
'message': 'Wichz would like to access your location to get your things.'
}
)
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
// console.warn("You can use locations ")
} else {
// console.warn("Location permission denied")
}
} catch (err) {
// console.warn(err)
}
}
this.watchID = navigator.geolocation.watchPosition((position) => {
this.setState({
selectedLat: position.coords.latitude,
selectedLng: position.coords.longitude
});
Global.selectedLat = position.coords.latitude;
Global.selectedLng = position.coords.longitude;
this.getcurrent_address(position.coords.latitude, position.coords.longitude);
}, (error)=>console.log(error.message), …Run Code Online (Sandbox Code Playgroud) 我正在使用react-native-map,它在ios和android上运行良好。
我的本机版本是0.61.2。但是在ios中,当我单击map时,显示警告“-[RCTRootView cancelTouches]`已过时,将很快被删除。”。
这是什么,以及如何删除此警告?