Skip to content
Advertisement

JavaScript function nearest geographical neighbor

I am looking for a JavaScript function who returns the nearest neighbor of a number. e.g: I am having a coordinate 12,323432/12,234223 and i want to know the nearest coordinate of a set of 20 other coordinates in a database. How to handle that?

Advertisement

Answer

The following 3 functions find the nearest coordinate from a javascript array using the Haversine formula.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement