A common operation in Maps API applications is to search a spatial database for locations within a certain distance of a point. It can also be useful to offer search along a route, for example to find hotels, restaurants, or service stations on a long journey. However if your spatial database does not support corridor queries this can be difficult to implement efficiently. For example searching around every vertex of a route will generate a large number of queries which overlap, while also leaving gaps in coverage between widely spaced vertices.
Polyline object or array of
LatLng objects and returns a set of non-overlapping bounding boxes that are guaranteed to encompass every point within a specified distance of the line.
You can use the below demo to evaluate the boxes that are generated for a given route.