Camera
The camera namespace moves the viewport. It is the largest surface in the protocol, because the difference between a map that feels considered and one that does not is mostly camera work.
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.Reading and moving
const position = await map.camera.get();
// { center: { lat, lng }, zoom, bearing, pitch }
await map.camera.jumpTo({ zoom: 18 });
await map.camera.flyTo({ zoom: 18, bearing: 45, duration: 800 });
await map.camera.fitTo("muntz-hall");
await map.camera.cancel();
| Method | Argument | Effect |
|---|---|---|
get() | none | Current position, or null while the map is not rendering |
jumpTo(position) | CameraPosition | Moves instantly |
flyTo(position) | CameraPosition & CameraAnimation | Moves with animation |
fitTo(ref) | reference | Frames whatever the reference names |
cancel() | none | Stops any animation or path playback in progress |
Position
interface CameraPosition {
center?: { lat: number; lng: number };
zoom?: number; // 0 to 22
bearing?: number; // degrees, 0 is north
pitch?: number; // degrees from vertical, 0 to 60
}
Omitted fields are left alone, so flyTo({ zoom: 18 }) zooms without moving or
rotating.
Values outside these ranges are rejected with INVALID_PAYLOAD rather than
clamped. Silently moving the camera somewhere that was not asked for produces a
bug that is very hard to see; an error is not.