title: How to get accurate lat and long of current location in react native
body: <p>I want to get <code>latitude</code>, <code>longitude</code> of my current location. For that, I have installed <a href="https://github.com/react-native-community/react-native-geolocation" rel="nofollow noreferrer">react-native-geolocation</a> and implement it according to its document. But it is giving the wrong <code>latitude</code>, <code>longitude</code>. Same goes for <a href="https://github.com/Agontuk/react-native-geolocation-service" rel="nofollow noreferrer">react-native-geolocation-service</a>.</p>
  
  <p>Here the code I tried </p>
  
  <pre><code>import React from 'react';
  import { StyleSheet, Text, View, Alert } from 'react-native';
  import Geolocation from '@react-native-community/geolocation';
  
  export default class GeolocationExample extends React.Component {
    state = {
      latitude: 'unknown',
      longitude: 'unknown',
    };
  
    componentDidMount() {
  
     Geolocation.getCurrentPosition(
        position =&gt; {
          const latitude = JSON.stringify(position.coords.latitude);
          const longitude = JSON.stringify(position.coords.longitude);
          this.setState({ latitude, longitude });
        },
        error =&gt; Alert.alert('Error', JSON.stringify(error)),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
      );
    }
  
    render() {
      const { latitude, longitude } = this.state;
      console.log(latitude, longitude);
  
      return (
        &lt;View&gt;
          &lt;Text&gt;
            &lt;Text style={styles.title}&gt;latitude: &lt;/Text&gt;
            {this.state.latitude}
          &lt;/Text&gt;
          &lt;Text&gt;
            &lt;Text style={styles.title}&gt;longitude: &lt;/Text&gt;
            {this.state.longitude}
          &lt;/Text&gt;
        &lt;/View&gt;
      );
    }
  }
  
  </code></pre>