I have a Data array with Points. When I calculate the distance from My location to those Points (Data.map) as long as the Points have positive latitude it works. As soon as I change the latitude to negative it stops working.
It calculates the distance between my coords.latitude & coords.longitude and the Points in the Data array. It’s a from the geolib library, alone by itself it works fine but the problem appears when I use map.
If I use positive latitude in Points it works fine.
But when I change the Points latitude to negative it doesn´t return anything (if I toggle the Boolean filter it returns NaN)
I replaced point B in the function with my lat & my long and it works fine calculating the distance to a point A.
The problem is when I try to map an array of Points.
With Data: [{id: '1', Point: '34.909021, -56.220080', A: '3',},...... it accepts the object.
But when I change the sign from 34 to -34 in Data: [{id: '1', Point: '-34.909021, -56.220080', A: '3',},...... the error appears.
I think it must have something to do with this line !!(coords.longitude && coords.latitude) &&, I suppose the double !! has something to do, but if I take it out NaN.
Yes you’re right Jeremy. The idea is to calculate the distance from MyLocation to all the markers in “Data array” (map it) and pick out the nearest one.
I agree it´s not clear