Control group component for grouping multiple controls together on MapLibre maps.
This component provides a container for grouping multiple button controls or other custom controls visually together, creating a cohesive control panel on the map.
Examples
Basic control group with buttons:
<.control_group
id="actions-group"
map_id="my-map"
position="top-right"
>
<.control_button icon="+" tooltip="Zoom In" phx-click="zoom_in" />
<.control_button icon="-" tooltip="Zoom Out" phx-click="zoom_out" />
<.control_button icon="π " tooltip="Home" phx-click="go_home" />
</.control_group>Horizontal control group:
<.control_group
id="tools-group"
map_id="my-map"
position="top-left"
orientation="horizontal"
>
<.control_button icon="βοΈ" tooltip="Draw" phx-click="start_draw" />
<.control_button icon="π" tooltip="Measure" phx-click="start_measure" />
<.control_button icon="ποΈ" tooltip="Clear" phx-click="clear_all" />
</.control_group>Group with mixed content:
def render(assigns) do
~H"""
<.map id="my-map" center={[-74.5, 40]} zoom={9} style={@style} class="h-96" />
<.control_group
id="layer-controls"
map_id="my-map"
position="top-right"
class="layer-controls-group"
>
<.control_button
icon="πΊοΈ"
tooltip="Layers"
active={@layers_visible}
phx-click="toggle_layers"
/>
<.control_button
icon="π"
tooltip="Search"
active={@search_visible}
phx-click="toggle_search"
/>
<.control_button
icon="βΉοΈ"
tooltip="Info"
phx-click="show_info"
/>
</.control_group>
"""
endMultiple groups at different positions:
<.control_group id="nav-group" map_id="my-map" position="top-right">
<.control_button icon="β¬οΈ" tooltip="North" phx-click="face_north" />
<.control_button icon="π" tooltip="Location" phx-click="my_location" />
</.control_group>
<.control_group id="tool-group" map_id="my-map" position="top-left">
<.control_button icon="π" tooltip="Measure" phx-click="measure" />
<.control_button icon="βοΈ" tooltip="Draw" phx-click="draw" />
</.control_group>
Summary
Functions
Renders a control group on the map.
Functions
Renders a control group on the map.
Attributes
id(required) - Unique identifier for the control groupmap_id(required) - ID of the map to add the control group toposition- Control position:"top-left","top-right","bottom-left","bottom-right". Defaults to"top-right"orientation- Layout orientation:"vertical"or"horizontal". Defaults to"vertical"class- Additional CSS classes to apply to the control group container
Slots
inner_block(required) - The controls to group together
Events
This component does not emit custom events. Child controls can use standard Phoenix
event bindings (phx-click, etc.).
Notes
- The control group acts as a single visual unit in the map's control system
- Child controls should typically be
control_buttoncomponents but can be any content - The group automatically applies proper spacing and styling to child elements
- Orientation affects the layout direction of grouped controls
- Multiple groups can be placed at different positions on the map
Attributes
id(:string) (required)map_id(:string) (required)position(:string) - Defaults to"top-right".orientation(:string) - Defaults to"vertical".class(:string) - Defaults to"".- Global attributes are accepted.
Slots
inner_block(required)