Reputation: 683
I'm searching for a solution to fetch geolocation on android and iOS through react-native without using the GPS.
It doesn't seem like the default geolocation module supports this, or am I mistaken ?
Upvotes: 3
Views: 1132
Reputation: 683
It seems like the function getCurrentLocation
takes an object of options as the last parameter which enables the location to be based on cell tower triangulation (or otherwise - at least without hitting the GPS).
navigator.geolocation.getCurrentPosition(
(position) => {
var initialPosition = JSON.stringify(position);
this.setState({initialPosition});
},
(error) => alert(JSON.stringify(error)),
{enableHighAccuracy: false, timeout: 20000, maximumAge: 1000}
);
Notice the enableHighAccuracy: false property.
Upvotes: 4