Skip to main content

Selection

Selection is what the map treats as the visitor's current focus. Selecting something opens the map's detail panel for it, switches to the right floor, and frames the camera on it.

Examples use a demonstration campus. Snippets on this site address ucba, a publicly available campus, and usually open the building muntz-hall. Some examples also pass a room prop when a specific location should be selected on load. 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.

Try the commands below against a live map. Each row shows the SDK call your code would make; edit the value and Send to drive the frame programmatically.

Your page sends the same calls through the SDK. Edit a value, then Send.

Waiting for map…

await map.selection.setRoom("muntz-hall/170")
await map.selection.setBuilding("muntz-hall", { floor: "second-floor" })

The optional floor value is a slugified floor label from this building's map data. Labels are set by the map builder; there is no standard vocabulary. second-floor works on this demo campus only because that is how Muntz Hall was published.

await map.selection.setFloor("muntz-hall/floor/second-floor")
await map.selection.clear()

Commands​

await map.selection.setBuilding("muntz-hall");
await map.selection.setBuilding("muntz-hall", { floor: "second-floor" });
await map.selection.setFloor("muntz-hall/floor/second-floor");
await map.selection.setRoom("muntz-hall/170");
await map.selection.clear();
MethodArgumentEffect
setBuilding(ref, options?)Building reference, optional { floor }Selects the building, optionally opening a specific floor
setFloor(ref)Floor referenceSwitches the active floor, clears any room selection, and reframes to the floor plan
setRoom(ref)Room referenceSelects the room, switches to its floor, and frames the camera on the room
clear()noneDismisses the current selection and its detail panel

Each resolves once the map has applied the change. An unresolvable reference rejects with REF_NOT_FOUND.

References​

Selection commands take references, not names and not identifiers.

Floor references are slugified labels from each building's published map data. The map builder sets those labels; there is no standard vocabulary across campuses. The examples below (second-floor, and so on) are specific to Muntz Hall on this demo campus. Read the slug back from selection.changed or map.getState() rather than assuming floor numbers or ordinal names will resolve.

FormExample
Buildingmuntz-hall
Floormuntz-hall/floor/second-floor
Roommuntz-hall/170

A room reference is qualified by its building because room slugs are only unique within one. When the map reports a selection back to you it gives the room bare, relative to the building in the same payload, so reassemble the two if you plan to send the value back.

map.on("selection.changed", ({ building, room }) => {
if (building && room) {
const ref = `${building}/${room}`;
}
});

The React room prop accepts either spelling and normalises internally.

The complete grammar, including here and pin: coordinates, is in the reference grammar.

Selection and the camera are separate​

Selecting a room frames it tightly. Selecting a floor reframes to the floor plan and clears any room selection. Selecting a building (without a floor) frames the building shell.

Framing alone does not change selection:

await map.camera.fitTo("muntz-hall"); // moves the viewport, changes nothing else
await map.selection.setBuilding("muntz-hall"); // selects, and framing follows

The separation exists so that a host rendering its own detail interface can suppress the map's panel with the panel chrome flag, drive framing itself, and never trigger the map's own selection behaviour. A host that wants the map's built-in behaviour uses selection and lets the framing follow.

Reacting to selection​

selection.changed fires for every change, whether the visitor caused it or you did. Filter on meta.source to react only to the visitor.

map.on("selection.changed", (selection, meta) => {
if (meta.source !== "user") return;
showAvailability(selection.building, selection.room);
});

The payload is { building, floor, room }, each a string or null.

Next​

  • Camera for framing without selecting.
  • Events for the full event catalogue.