Most drives don't just go from point A to point B: along the way, everyone needs to make rest stops, grab dinner, or refill & recharge their cars. What if directions made this easy?

In the simulation above, we locate all electric vehicle charging stations along a route in realtime, and make it possible to reroute to a charging station, highlighted in blue, with a single click. You can also drag the green beginning & end markers to plan a different trip.

Searching for places near a route is a tough problem, because it involves narrowing down thousands of potential locations to find out what's actually nearby. The demo uses Mapbox Directions to generate the initial route, displays the path with Mapbox.js, and then selects nearby charging stations from a dataset of 9,000 with Turf's .distance() method.