Answer the question
In order to leave comments, you need to log in
How to calculate the nearest location?
There is a variable myCoordinate and there is an array allCoordinates
const myCoordinate = {
"lat": 53.9256183,
"lng": 27.512342
}
const allCoordinates = [{
"lat": 53.9256183,
"lng": 27.512342
}, {
"lat": 23.92234183,
"lng": 54.534342
}, {
"lat": 54.9226183,
"lng": 32.5122342
}]
Answer the question
In order to leave comments, you need to log in
Have a look at the Haversine formula: https://en.wikipedia.org/wiki/Haversine_formula
Example (there is an implementation in JS): www.movable-type.co.uk/scripts/latlong.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question