1

I am android developer and I want to retrieve nearest restaurant detail based on user entered latitude and longitude detail.

RAS
  • 8,100
  • 16
  • 64
  • 86
Kashyap
  • 31
  • 1
  • 1
  • 2

1 Answers1

-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

1: http://www.movable-type.co.uk/scripts/latlong.html

Community
  • 1
  • 1
nxasdf
  • 1,088
  • 1
  • 11
  • 11