问题描述:

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 ?

网友答案:

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.

相关阅读:
Top