title: React Native calculating the distance between two coordinates using GeoLib
body: <p>I have two issues. One is I can see the  Longitude and Latitude of my current location if I start the application using command react native run-android. If I reload the screen, I get a timeout error saying "Location Request timed out" and I don't see Longitude and Latitude. Below is the image</p>
  
  <p><a href="https://i.stack.imgur.com/0ytnY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ytnY.png" alt="enter image description here"></a></p>
  
  <p>Another issue I am having is when I tried to calculate the  distance between two coordinates of Longitude and Latitude then I get  path error. Below is my code and the screen shot of the error:</p>
  
  <pre><code>import React, { Component } from 'react';
  import { View, Text, TouchableOpacity, Linking } from 'react-native';
  import geolib from "geolib";
  
  class GeolocationExample extends Component {
    constructor(props) {
      super(props);
  
      this.state = {
        latitude: null,
        longitude: null,
        error: null,
      };
    }
  
  
  
    componentDidMount() {
      navigator.geolocation.getCurrentPosition(
        (position) =&gt; {
          this.setState({
            latitude: position.coords.latitude,
            longitude: position.coords.longitude,
            error: null,
          });
        },
        (error) =&gt; this.setState({ error: error.message }),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
      );
    }
  
    render() {
  
      let geolib = require('geo-lib');
  
  
      let result =geolib.Distance({
       p1: { lat: this.state.latitude, lon: this.state.longitude },
       p2: { lat: 33.613355, lon: -117.373261 }
   });
  
  
      return (
        &lt;View style={{ flexGrow: 1, alignItems: 'center', justifyContent: 'center' }}&gt;
          &lt;Text&gt;Latitude: {this.state.latitude}&lt;/Text&gt;
          &lt;Text&gt;Longitude: {this.state.longitude}&lt;/Text&gt;
          &lt;Text&gt;Distance between two points:result &lt;/Text&gt;
          {this.state.error ? &lt;Text&gt;Error: {this.state.error}&lt;/Text&gt; : null}
  
  
        &lt;/View&gt;
      );
    }
  }
  
  export default GeolocationExample;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rc3bP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rc3bP.png" alt="enter image description here"></a></p>
  
  <p>I am not sure why this error is coming up.</p>
  
  <p>Any help will be greatly appreciated.</p>