attribution_control
StableShows the attribution of the map's sources.
position
Set assigns
- @enabled
- true
- @position
- bottom-right
- @compact
- false
- @custom_attribution
- nil
- @map_attribution
- true
<div id="attribution-control-example">
<.example_frame error={@map_error} error_id="example-attribution-map-error">
<.map
id="example-attribution-map"
center={[2.3522, 48.8566]}
zoom={12}
attribution_control={@map_attribution}
style={basemap(@theme)}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<%!-- While it is on the page, the component takes the place of the map's
own attribution, so the map shows one. A new position moves it; a new
compact or custom_attribution replaces it in the same place. --%>
<.attribution_control
:if={@enabled}
id="example-attribution"
map_id="example-attribution-map"
position={@position}
compact={@compact}
custom_attribution={custom_attribution(@custom)}
/>
<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-attribution-positions" label="position" code>
<.example_button
:for={position <- positions()}
id={"example-attribution-position-#{position}"}
code
pressed={@position == position}
phx-click="position"
phx-value-position={position}
>
{position}
</.example_button>
</.example_group>
<.example_group id="example-attribution-assigns" label={gettext("Set assigns")}>
<.form
for={@options}
id="example-attribution-options"
phx-change="options"
class="flex flex-wrap gap-x-6 gap-y-2 py-1.5"
>
<.example_checkbox field={@options[:enabled]} label=":if" />
<.example_checkbox field={@options[:compact]} label="compact" />
<.example_checkbox field={@options[:custom]} label="custom_attribution" />
<.example_checkbox field={@options[:map]} label="<.map attribution_control>" />
</.form>
</.example_group>
</div>
<.example_readout values={[
enabled: @enabled,
position: @position,
compact: @compact,
custom_attribution: custom_attribution(@custom) || "nil",
map_attribution: @map_attribution
]} />
</div>