Routing

Finds a route, distance and travel time.

type: routingtoolbarstable

What it does

Routing uses a start and an end point to get a route with its distance and duration.

This is different from Measure. Measure gives a straight-line distance, or the length of a line you drew. Routing gives distance along roads, paths or cycleways.

Four services are offered, and they differ in what you have to bring and in what they can answer:

The two free ones are public community servers, offered without a key and therefore without a quota anyone is accounting for. Treat them as public test services: they are rate-limited, and they are occasionally unreachable. A keyed service is the one to use for a map that has to work on a given afternoon.

A truck profile can use axle weight and dimensions, because those can change which roads are allowed.

A route can be kept. By default the route is temporary. Persist it and the route becomes a normal layer that can be measured, exported, and used in Analysis.

Using it

  1. Open routing and click the start point on the map, then the end.
  2. Choose a travel mode. The route, its distance, and its duration appear.
  3. Clear removes the route. Persist to map keeps it as a layer.

Duration is the service's estimate for the profile chosen, not a promise about traffic on the day.

In your own map

Add routing to a toolbar. OSRM and Valhalla work immediately. OpenRouteService and TomTom need their key, supplied through the map's API key setting or a {key-…} placeholder in the config, which is resolved from the apikeys.json beside the config.

All four are third-party services with their own usage policies. A map expected to carry real traffic should use its own instance rather than the public servers. Expect the free ones to be unavailable sometimes, since a service nobody is paying for owes nobody an uptime.

Extending it

A service definition lists its modes and the function that requests a route. Adding another service should be one new definition, not a new tool.

Config typerouting
Element<webmapx-routing-tool>
Placementtoolbar
Sourcesrc/components/webmapx-routing-tool.ts
Teststests/tool-registration.test.ts
Relatedisochrone, measure, search