A button that switches the map between the flat mercator projection and a globe.
<HoloMap.Control.Globe position="top-right" />It adds MapLibre's GlobeControl, which MapLibre GL JS has shipped since
5.0.0. The projection is a rendering choice, not data: the same sources and
layers draw either way, and nothing in your components needs to know which
is active.
Props
| Prop | Type | Notes |
|---|---|---|
position | string | Corner to place the control in. Default "top-right" |
The control takes no options of its own, because MapLibre's GlobeControl
constructor accepts none.
With the projection prop
HoloMap.Map's projection prop sets the projection from state, and the
control switches it as the user clicks. A click holds until the prop's value
changes or the style does, which put the prop's projection back. The map's
on_projection_transition reports each click, with the new projection, so
an action can write it back into the state the prop reads:
<HoloMap.Map cid="world" style={@style} projection={@projection}
on_projection_transition={:projection_changed}>
<HoloMap.Control.Globe />
</HoloMap.Map>
def action(:projection_changed, params, component) do
put_state(component, :projection, params.projection)
endThe control shows as on only while the projection is "globe". A click
switches to "globe" from mercator, or from a style that declares no
projection, and to "mercator" from anything else, an expression or
"vertical-perspective" among them.
When a globe helps
At low zoom the mercator projection inflates everything far from the equator, which is the wrong story for anything global: coverage maps, flight paths, climate data. A globe removes that distortion and makes polar regions readable. Past roughly zoom 6 the two are indistinguishable, so the control earns its place on world views and clutters a city map.
Pair it with HoloMap.Control.Navigation. A rotated globe is much easier to
reset with a compass than by dragging.
Summary
Functions
Returns true to indicate that the callee module is a component module (has "use Hologram.Component" directive).
Returns the list of property definitions for the compiled component.
Functions
@spec __is_hologram_component__() :: boolean()
Returns true to indicate that the callee module is a component module (has "use Hologram.Component" directive).
Examples
iex> __is_hologram_component__()
true
Returns the list of property definitions for the compiled component.