gistda-sphere-react

Routing

Plan a route and show turn-by-turn directions

Plan a route between two cities and list the directions:

Variations

  • Several stops: call addDestination for each stop. Each pair of stops is a leg in route.routes.
  • Let users plan on the map: route.enableContextMenu() adds "Direction to here" to the right-click menu. Stops can be dragged, and the route updates by itself.
  • Sphere's own panel: render <RouteGuide> next to the map.
  • No map at all: the routing web service returns the same data as GeoJSON.

If nothing happens and you get a "timeout" error after 20 seconds, your API key doesn't have the routing service. "Straight line" mode works without it.

On this page