Navigation
The SDK provides routing capabilities to generate and render turn-by-turn directions between two or more points on a Unit Map®. Navigation is available on supported maps and is accessed via the UnitMap.nav() method.
Provide an ordered list of waypoints — each an [x, y] point on a specific floor — and the routing service returns a Trip. A trip is broken into one TripLeg per pair of consecutive waypoints, and each leg is further divided into floor segments of Maneuver steps.
var waypoints = [
{ point: [348.64, 569.37], floor_id: "1010" },
{ point: [963.03, 836.97], floor_id: "1010" }
];
map.nav().directions(waypoints, function (error, trip) {
if (error) {
console.error(error);
return;
}
// Fit the map to the generated trip:
map.fitBounds(trip.bounds(), { padding: 100 });
});The generated directions are rendered onto the map automatically. Review the Nav reference for the full set of routing options, including pedestrian modes, conditional waypoints, and exclusions.
Directions are generated by the Unit Map® SDK and require a network request, so the result is delivered asynchronously to the provided callback.
Updated 1 day ago
