LevelControl
Class: LevelControl
Opt-in indoor level switcher, implemented as a maplibre IControl.
Renders one button per level of the current building (top floor first), reflects the active level, and calls WemapMap.setLevel on click. It subscribes to building/level changes itself and shows nothing when there is no indoor building in view.
It is not added automatically — opt in with WemapMap.addControl:
const map = new WemapMap({ container });
await map.whenReady();
map.addControl(new LevelControl(map));
Styling relies on maplibre's own maplibregl-ctrl-group control CSS (from
maplibre-gl/dist/maplibre-gl.css, which you already import), plus a small
inline highlight for the active level — no extra stylesheet required.
Implements
Constructors
Constructor
new LevelControl(
wemapMap,options?):LevelControl
Parameters
wemapMap
options?
LevelControlOptions = {}
Returns
LevelControl
Methods
getDefaultPosition()
getDefaultPosition():
ControlPosition
Optionally provide a default position for this control. If this method
is implemented and Map.addControl is called without the position
parameter, the value returned by getDefaultPosition will be used as the
control's position.
Returns
a control position, one of the values valid in addControl.
Implementation of
IControl.getDefaultPosition
onAdd()
onAdd(
_map):HTMLElement
Register a control on the map and give it a chance to register event listeners and resources. This method is called by Map.addControl internally.
Parameters
_map
Returns
HTMLElement
The control's container element. This should be created by the control and returned by onAdd without being attached to the DOM: the map will insert the control's element into the DOM as necessary.
Implementation of
IControl.onAdd
onRemove()
onRemove():
void
Unregister a control on the map and give it a chance to detach event listeners and resources. This method is called by Map.removeControl internally.
Returns
void
Implementation of
IControl.onRemove