当前位置: 动力学知识库 > 问答 > 编程问答 >

Retrieving geo location in react-native without GPS

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: