fullscreen_control
StableA button that shows the map in full screen.
position
container_id
- @position
- top-right
- @container_id
- nil
- @fullscreen
- false
<div id="fullscreen-example" class="bg-canvas">
<.example_frame error={@map_error} error_id="example-fullscreen-map-error">
<.map
id="example-fullscreen-map"
center={[18.4232, -33.9188]}
zoom={12}
style={basemap(@theme)}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<%!-- The control follows its assigns: a new position moves it, a new
container_id replaces it in the same place. --%>
<.fullscreen_control
id="example-fullscreen"
map_id="example-fullscreen-map"
position={@position}
container_id={@container_id}
events={["fullscreen:entered", "fullscreen:exited"]}
/>
<div class="grid gap-x-8 gap-y-4 border-t border-line px-4 py-4 lg:grid-cols-[auto_1fr]">
<.example_group id="example-fullscreen-positions" label="position" code>
<.example_button
:for={position <- positions()}
id={"example-fullscreen-position-#{position}"}
code
pressed={@position == position}
phx-click="position"
phx-value-position={position}
>
{position}
</.example_button>
</.example_group>
<.example_group id="example-fullscreen-containers" label="container_id" code>
<.example_button
:for={{name, id} <- containers()}
id={"example-fullscreen-container-#{name}"}
code
pressed={@container_id == id}
phx-click="container"
phx-value-container={name}
>
{inspect(id)}
</.example_button>
</.example_group>
</div>
<%!-- fullscreen:entered and fullscreen:exited keep fullscreen current. --%>
<.example_readout values={[
position: @position,
container_id: inspect(@container_id),
fullscreen: @fullscreen
]} />
</div>
Generated from the component's definition in the library, so it always matches the version this demo runs.
| Attribute | Type | Default | Description |
|---|---|---|---|
| id required | string | — | Unique identifier for the control |
| map_id required | string | — | ID of the map to add the control to |
| position | string |
"top-right"
|
Control position: "top-left", "top-right", "bottom-left", "bottom-right". Defaults to "top-right". A new value moves the control to that corner
|
| container_id | string |
nil
|
ID of the HTML element to make fullscreen. If not provided, defaults to the map container. The element has to be on the page when the control is created. MapLibre takes it only when it creates the control, so a new value replaces the control with a new one, in the same place. A page in fullscreen through the control it replaces stays in fullscreen, and leaving it pushes no fullscreen:exited
|
| global attributes | global | — | Any other HTML attribute, passed on to the component's element. |
| events | any |
[]
|
a list of event names, or :all
|