Add routing to your app

Use E2's RouteClient for routes, matrices, reachable areas, map matching, and other network operations.

Documentation navigation

Get a route

routing.ts
import { E2 } from "@embed-earth/sdk-test";

const e2 = new E2();
const route = await e2.route.route({
  locations: [
    { lat: 40.74, lon: -73.99 },
    { lat: 40.71, lon: -74.01 },
  ],
  mode: "walking",
});

Operations

MethodUse
route()Turn-by-turn route between locations.
directions()Alias for route().
matrix()Travel times between source and target locations.
isochrone()Reachable areas for time or distance contours.
mapMatch()Match a shape to the road network.
locate()Locate coordinates on the network.
height()Request elevation data.
request()Send a custom routing request.

Matrix and isochrones

network.ts
const matrix = await e2.route.matrix({
  sources: [{ lat: 40.74, lon: -73.99 }],
  targets: [{ lat: 40.71, lon: -74.01 }],
  mode: "driving",
});

const area = await e2.route.isochrone({
  locations: [{ lat: 40.74, lon: -73.99 }],
  mode: "walking",
  contours: [{ time: 10 }, { time: 20 }],
});

Route to a feature

feature-route.ts
const routeToRestaurant = await e2.route
  .feature("restaurant")
  .from({ lat: 40.74, lng: -73.99 })
  .area("Manhattan")
  .nearest({ mode: "walking" });

E2 searches the selected feature and area, chooses the nearest routable point, and sends the resulting coordinates to Valhalla.

Time-aware and custom requests

valhalla.ts
const route = await e2.route.route({
  locations,
  mode: "driving",
  date_time: { type: 1, value: "2026-08-18T09:00" },
});

const located = await e2.route.request("/locate", {
  locations: [{ lat: 40.74, lon: -73.99 }],
});

Route modes include driving, walking, cycling, multimodal, truck, motorcycle, motor_scooter, bus, taxi, hov, and transit. Additional request fields are passed through to the routing service.