On one hand I have a main latitude and a longitude 40.4168,-3.7038,for example (both separated like this: {latitude:40.4168 , longitude:-3.7038}
) and on the other hand I have an array of places that have latitude and longitude data (both separated too like this
[
{lat1:lat1Value,lon1:lon1Value},
{lat2:lat2Value,lon2:lon2Value},
{lat3:lat3Value,lon3:lon3Value}
...]
I want to calculate the nearest location of this array to my main latitude-longitude, what is the most efficient/cleanest way to resolve this problem in javascript ??