Skip to content

Walking directions

The same route() call, with mode: "pedestrian". The engine uses the walking profile: sidewalks and paths where the data has them, and a walking speed for the duration.

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: "pedestrian" });

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 },
  });
});

durationSeconds is still seconds, not minutes. A fifteen-minute walk is 900. The geometry is the walking path, which can differ from the driving path on the same two points.

mode is 'auto' | 'car' | 'bicycle' | 'pedestrian' | 'truck' | 'transit'. car and auto are the same driving profile. See Travel modes for the others, and the Routing API for the contract.