1

I have set of lat/long which are stored in database and I have to find all the lat/long from the database which are lies between the given lat/long(e.glatitude = 37.4224764,and longitude=-122.0842499) and given radius(say 5miles).For this I need to do some addition and subtraction like:

37.4224764 + 5mile 37.4224764 - 5mile and

-122.0842499+5mile -122.0842499-5mile But I don't know how the conversion works here.

ABC
  • 4,263
  • 10
  • 45
  • 72
  • possible duplicate of [How do I know if a Lat,Lng point is contained within a circle?](http://stackoverflow.com/questions/4463907/how-do-i-know-if-a-lat-lng-point-is-contained-within-a-circle) – duncan Apr 11 '15 at 16:07
  • See this answer http://stackoverflow.com/questions/25478006/how-to-get-the-nearest-100-points-from-one-million-data-records-quickly/25813558#25813558 – Michael Diomin Apr 23 '15 at 17:03

1 Answers1

0

You're a little vague in your requirements, do you just want to find out the coordinates of a point a certain distance from your current location in a given direction? Or get a circle of a radius of a particular distance around your coordinates? Or draw a line of a certain length from your coordinates to another point a particular distance away?

I assume you'd probabaly want to use the Geometry spherical library, e.g.

var latLng = new google.maps.LatLng(geometry.location.lat, geometry.location.lng);

var newLatLng = google.maps.geometry.spherical.computeOffset(
    latLng,
    1000, 
    0
);

see also https://developers.google.com/maps/documentation/javascript/geometry#Distance

PS: you need to add the geometry library parameter when loading the map:

<script src="https://maps.googleapis.com/maps/api/js?v=3&libraries=geometry"></script>
duncan
  • 31,401
  • 13
  • 78
  • 99