Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you are using the <a href="https://developers.google.com/maps/documentation/javascript/reference#PlaceSearchRequest" rel="nofollow">Place Search Request</a> method you can use the bounds parameter instead of location and radius.</p> <p>Otherwise you could use the Google Maps API method using the centre of your box as the centre of the circle and half of the diagonal of the box as the radius of the circle. This will give you all of the places within the circle enclosing the box. You can then scan through the set removing any places that are inside the circle but outside of the box.</p> <p>Adding rankby=distance to the method call would sort the results in order of distance from the specified location (e.g. the centre of the box.) If you need to sort in order of distance from the route you would need to calculate the distance from the route. The simplest way to do this is to calculate a perpendicular to each line segment in the route using vector projection. If the projected point is off one end of the line segment, the distance is to the end point of that end of the line. The sign of the distance along the vector will tell you which end to test. The distance to the closest line segment is the shortest distance to the route.</p> <p>The closest method in the Google Maps API V3 is: <a href="https://developers.google.com/maps/documentation/javascript/reference#DistanceMatrixService" rel="nofollow">DistanceMatrixService</a> which finds the distance between multiple source and destination locations. There are a few other methods that might help with parts of the calculation, but I can't see anything that finds the distance between a route/polyline and a place/point.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload