how to create maps which detect automatic location in React-Native
<p>I have created maps in react-native referring to <a href="https://github.com/lelandrichardson/react-native-maps" rel="noreferrer">https://github.com/lelandrichardson/react-native-maps</a>
map is created but i want to detect automatic location using gps. Here is the code which renders map with static latitude and longitude.
Here's my updated code. But it still not rendering perfect location</p>

<pre><code>getInitialState() {
    return {
        initialPosition: 'unknown',
        lastPosition: 'unknown',
    };
  },

  componentDidMount() {
    navigator.geolocation.getCurrentPosition(
      (position) =&gt; {
        var initialPosition = JSON.stringify(position);
        this.setState({initialPosition});
      },
      {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
    );
    this.watchID = navigator.geolocation.watchPosition((position) =&gt; {
      var lastPosition = JSON.stringify(position);
      this.setState({lastPosition});
    });
  },

  componentWillUnmount() {
    navigator.geolocation.clearWatch(this.watchID);
  },

  render() {
    return (
      &lt;View style={styles.container}&gt;
        &lt;MapView
          ref="map"
          mapType="terrain"
          style={styles.map}
          initialPosition={this.state.initialPosition}
          lastPosition={this.state.lastPosition}
        &gt;
        &lt;/MapView&gt;
      &lt;/View&gt;
</code></pre>

<p>can you please correct it?</p>

<p>Thanks in advance </p>