Skip to main content

Itinerary Routes

ItineraryLayer draws a route path on the map, splitting the geometry per floor so indoor/outdoor and multilevel segments render correctly.

import { Coordinates } from '@wemap/geo';
import { WemapMap, ItineraryLayer } from '@wemap/map';

const map = new WemapMap({ container: 'map' });
const route = new ItineraryLayer(map);

route.set({
coords: [
new Coordinates(48.8566, 2.3522, null, 0),
new Coordinates(48.8568, 2.3525, null, 1),
// …
],
});

coords is a LatLngLike[] (each accepts a Coordinates, a { lat, lng, level? } object, or a [lat, lng, level?] tuple); each coordinate may carry a level so the route follows the displayed floor (via setLevel). Route colour defaults to the theme primary and follows the map level automatically.

route.set(itinerary, { fitBounds: true }); // fit the camera to the route
route.set(itinerary, { color: '#ff0000', width: 8 }); // restyle
route.clear(); // remove the route
route.destroy(); // tear down (or map.remove({ layers: true }))

Calling set again replaces the route (no duplication), and the drawn route is re-applied automatically across a style swap.

For the full API, see the ItineraryLayer reference.