HoloMap.Control (HoloMap v0.3.0)

Copy Markdown View Source

Namespace for MapLibre's built-in map controls.

<HoloMap.Map cid="explorer" style={@style}>
  <HoloMap.Control.Navigation position="top-right" />
  <HoloMap.Control.Scale unit="metric" position="bottom-left" />
</HoloMap.Map>

Every control takes a position: "top-left", "top-right", "bottom-left" or "bottom-right", defaulting to "top-right". Several controls in the same corner stack in the order they are declared.

Available controls

Attribution

MapLibre adds an attribution control on its own unless told otherwise. Adding HoloMap.Control.Attribution on top of that produces two. Set attribution_control={false} on HoloMap.Map when you want to place it yourself.

Attribution is usually a licensing obligation rather than a design choice, so removing it entirely is generally not yours to decide. Prefer compact.

Updates

Controls carry no updatable state that is worth diffing, so any prop change removes and re-adds the control, which keeps its place in its corner. That is invisible for the built-ins here, but it does mean a control is not the place to put a rapidly changing value.

An event handler is not part of that. HoloMap.Control.Geolocate and HoloMap.Control.Fullscreen report their events (see each module), and a change to a handler alone moves the listeners and leaves the control as it is. A control rebuilt for any other prop has its listeners moved to it.

Summary

Functions

The four corners a control can be placed in.

Functions

positions()

@spec positions() :: [String.t()]

The four corners a control can be placed in.

iex> HoloMap.Control.positions()
["top-left", "top-right", "bottom-left", "bottom-right"]