I send these paramaters my script : Latitude : 41.0186 Longitude : 28.964701 (it is sample). i want to find nearest location\'s name. how to do this? (query\'s where code\'s mus
I think this is not so easy as it feels. You must do some trigonometry calculations to get the nearest positsion to your location.
Found nice Javascript example:
var R = 6371; // km Radius of earth
var dLat = (lat2-lat1).toRad();
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;
It gives you the distance between the points.
Or you can try to pass in a sort order of the squared delta values of the long and lats:
(( - LAT_COLUMN) * ( - LAT_COLUMN) +
( - LNG_COLUMN) * ( - LNG_COLUMN))