Saltar al contenido

control_group

Estable

Agrupa varios controles en un solo control del mapa.

orientation

Usa los tres botones de la esquina superior izquierda del mapa o haz zoom tú mismo: map:moved mantiene al día el assign zoom.

@zoom
11
@orientation
vertical
lib/maplibrex_demo_web/examples/control_group_example.html.heex
<div id="control-group-example">
  <.example_frame error={@map_error} error_id="example-control-group-map-error">
    <.map
      id="example-control-group-map"
      center={[-99.1332, 19.4326]}
      zoom={@zoom}
      style={basemap(@theme)}
      events={["map:moved", "map:error"]}
      class="h-full w-full"
    />
  </.example_frame>

  <%!-- Each <.control_button> in the group is shown inside it, in template
        order; active tints the current level. A new orientation applies to
        the same group. --%>
  <.control_group
    id="example-control-group"
    map_id="example-control-group-map"
    position="top-left"
    orientation={@orientation}
  >
    <.control_button
      :for={level <- levels()}
      id={"example-control-group-#{level.id}"}
      map_id="example-control-group-map"
      tooltip={label(level.id)}
      active={@zoom == level.zoom}
      class="grid! place-items-center"
      phx-click="zoom"
      phx-value-level={level.id}
    >
      <.icon name={level.icon} class="size-5" />
    </.control_button>
  </.control_group>

  <div class="space-y-4 border-t border-line px-4 py-4">
    <.example_group id="example-control-group-orientations" label="orientation" code>
      <.example_button
        :for={orientation <- orientations()}
        id={"example-control-group-orientation-#{orientation}"}
        code
        pressed={@orientation == orientation}
        phx-click="orientation"
        phx-value-orientation={orientation}
      >
        {orientation}
      </.example_button>
    </.example_group>

    <.example_note id="example-control-group-hint" icon="hero-cursor-arrow-rays-micro">
      {gettext(
        "Use the three buttons in the map's top-left corner, or zoom the map yourself: map:moved keeps the zoom assign current."
      )}
    </.example_note>
  </div>

  <.example_readout values={[zoom: @zoom, orientation: @orientation]} />
</div>