Leaflet RouteBoxer
This is a Leaflet implementation of Google's RouteBoxer class.
The RouteBoxer class generates a set of L.LatLngBounds objects that are guaranteed to cover every point within a specified distance of a path, such as that generated for a route by an OSRM directions service.
Example
Check out the example demo
Usage
You need to pass an array of L.Latlng objects (route) to the L.RouteBoxer.
var route = 505 305 504 306 503 307;var distance = 10; // Distance in kmvar boxes = LRouteBoxer;
Using w/ OSRM service
OSRM uses polyline encoding to save bandwith. To decode the polyline you can use Leaflet.encoded.
// data.route_geometry is the result from a OSRM endpointvar route = LPolylineUtil;var distance = 10; // Distance in kmvar boxes = LRouteBoxer;