Directions
Directions draw a route between two references, indoors and out.
ucba, a publicly available campus with the building muntz-hall and the room 170. Substitute your own campus slug once you have one. Slugs for your campus are listed in your Waylocate console, and the addressing rules are in the reference grammar.Commands
await map.directions.start({ from: "here", to: "muntz-hall/170" });
await map.directions.clear();
| Method | Argument | Effect |
|---|---|---|
start(options) | StartDirections | Draws a route and opens the directions interface |
clear() | none | Removes the route and closes the interface |
Options
interface StartDirections {
from?: string; // reference; omit to let the visitor choose
to: string; // reference; required
mode?: "preview" | "live"; // default "preview"
accessible?: boolean; // prefer step-free routing
}
Both endpoints take any reference from the grammar, which means a route can start at the visitor's position and end in a room:
await map.directions.start({ from: "here", to: "muntz-hall/170" });
await map.directions.start({ from: "muntz-hall/170", to: "pin:39.1329,-84.5150" });
Omitting from opens the directions interface with the destination filled in
and lets the visitor pick a starting point.
mode selects between showing the whole route at once and following the
visitor along it. accessible: true prefers step-free paths where the campus
data describes them.
Reacting to routes
map.on("directions.changed", (directions) => {
if (!directions) return hideRouteSummary();
showRouteSummary(directions.from, directions.to, directions.status);
});
The payload is { from, to, mode, status }, or null when directions were
cleared. Endpoints that cannot be expressed as a reference, such as a point the
visitor tapped on the map, come through as null rather than failing.
Framing the route
The route and the camera are independent. Fit the viewport to the whole route with the reserved reference:
await map.camera.fitTo("route");
This returns NOT_READY when no route is drawn.
To animate along the route rather than framing it, see
followRoute.
Starting from the URL
Routes can be set before any JavaScript runs, using the from, to, and nav
query parameters. This is the only part of the directions surface available to a
static iframe.
https://waylocate.com/ucba?embed=1&from=here&to=muntz-hall/170&nav=live
Hiding the directions chrome with ui=-directions hides the entry points, not
the capability: a route set through the URL or through directions.start still
renders.
Next
- Appearance for hiding the map's own directions interface while keeping routes.
- Events for the full event catalogue.