title: How To Get All The Nearest Location With TurfJS?
body: <p>I'm doing React Native App uses Maps, And work with Real-time DB Firebase to get all data contained latitude, longitude, etc. </p>
  
  <p>I get current location [latitude and longitude] calculate the distance between the current location and the nearest I get in with TurfJs </p>
  
  <p>My issue is I need to display all Users from DB which are nearest to my current location.
  but the function just gets the first one nearest! How To Handle this?</p>
  
  <p>Node
  <a href="https://i.stack.imgur.com/1mpAa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1mpAa.png" alt="Node"></a></p>
  
  <p>Function</p>
  
  <pre><code>handleNearby = () =&gt; {
  const { region, providers } = this.state;
    let points = providers.map(p =&gt;
      turf.point([p.coordinates.latitude, p.coordinates.longitude])
    );
    let collection = turf.featureCollection(points);
    let currentPoint = turf.point([region.longitude, region.latitude]);
    let nearest = turf.nearestPoint(currentPoint, collection);
    let addToMap = [currentPoint, points, nearest];
    console.log(nearest);
    console.log(Math.floor(nearest.properties.distanceToPoint)); // let's say 50Km
  };
  
  &lt;MapView
    style={[styles.map, { width: this.state.width }]}
    style={StyleSheet.absoluteFill}
    // onMapReady={() =&gt; console.log(this.state.region)}
    showsUserLocation={true}
    region={region}
    loadingEnabled={true}
    // style={StyleSheet.absoluteFill}
    textStyle={{ color: "#bc8b00" }}
    containerStyle={{ backgroundColor: "white", borderColor: "#BC8B00" }}
  &gt;
    &lt;Marker
      coordinate={region}
      title="Hello"
      description="description"
      pinColor="navy"
      // onPress={() =&gt; alert("Provider Profile")}
      // icon={require('../assets/camera-icon.png')}
      onCalloutPress={() =&gt; alert("Provider Profile")}
    /&gt;
    //
    {this.state.providers.map((marker, index) =&gt; (
      &lt;Marker
        key={index}
        coordinate={marker.coordinates}
        title={marker.username}
      /&gt;
    ))}
    // Nearest Point Marker Should Be Here
  &lt;/MapView&gt;;
  </code></pre>