Reputation: 21
Trying to fetch current Location using geoLocation
, it is not working in React Native version(0.60) and above, But it is working in below versions
I realised, GeoLocation
folder is not there in nodeModules/React-Native/Libraries,
did they remove it from ReactNative(0.60)?
navigator.geolocation.getCurrentPosition((position) => {
console.log(position)
},
(error) => alert(JSON.stringify(error)),)
Getting this error:
Type Error: Undefined is not an object(evaluating 'navigator.geolocation.getCurrentPosition
Upvotes: 1
Views: 3081
Reputation: 367
npm install @react-native-community/geolocation --save
react-native link @react-native-community/geolocation
then:
import Geolocation form '@react-native-community/geolocation';
Geolocation.etCurrentPosition((position) => {
console.log(position)
},
(error) => alert(JSON.stringify(error))
Upvotes: 0
Reputation: 2974
It seems geolocation
has been removed from react native .60 version.
Try this:
npm install @react-native-community/geolocation --save
react-native link @react-native-community/geolocation
You can check this related SO post for more details.
Upvotes: 2