All examplesRouting
Travel modes
mode picks the costing profile. This is a bicycle route across the same two Calgary points as Get directions.
live result
the code that produced it
import { Unmap } from "@unmap/sdk";
const unmap = new Unmap({
key: "um_live_...",
container: "map",
center: [-114.03, 51.07],
zoom: 11,
});
const route = await unmap.router.route([-114.0719, 51.0447], [-113.9871, 51.0899], { mode: "bicycle" });
unmap.map!.on("load", () => {
unmap.map!.addSource("route", {
type: "geojson",
data: { type: "Feature", properties: {}, geometry: route.geometry },
});
unmap.map!.addLayer({
id: "route-line",
type: "line",
source: "route",
layout: { "line-cap": "round", "line-join": "round" },
paint: { "line-color": "#FF3E9A", "line-width": 3 },
});
});The five values are auto, car, bicycle, pedestrian, and truck. car is the same driving profile as auto; it exists because auto reads as "automatic" to anyone who does not know Valhalla. Anything else is a 400.
truck takes an optional vehicle profile (height, width, length, weight, and the rest) that the other modes reject. Defaults, ranges, and what the data covers are on the Routing API.