I am android developer and I want to retrieve nearest restaurant detail based on user entered latitude and longitude detail.
Asked
Active
Viewed 785 times
1 Answers
-1
Already been answered here (distance between latitude and longitude coordinates). To quote:
This link might be helpful to you.
Excerpt:
This script calculates great-circle distances between the two points – that is, the shortest distance over the earth’s surface – using the ‘Haversine’ formula.
Javascript:
var R = 6371; // Radius of the earth in km var dLat = (lat2-lat1).toRad(); // Javascript functions in radians var dLon = (lon2-lon1).toRad(); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a),
Math.sqrt(1-a)); var d = R * c; // Distance in km
-
I don't even remember writing this. What was I thinking? – nxasdf Feb 06 '15 at 03:43