vector_tile_source
EstableAñade teselas vectoriales, desde una URL TileJSON o una plantilla de teselas, para que las dibujen las capas.
Cambiar assigns
:if
- @continent
- Europe
- @enabled
- true
- @status
- waiting
- @data_events
- 0
<div id="vector-tile-source-example">
<.example_frame
error={@map_error}
error_id="example-vector-map-error"
hosts={["tiles.openfreemap.org", "demotiles.maplibre.org"]}
>
<.map
id="example-vector-map"
center={[15, 25]}
zoom={1.3}
style={basemap(@theme)}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<%!-- MapLibre's demo tiles: Natural Earth countries in a "countries" source
layer, up to zoom 6. A tile template, so the attribution given here
is the one shown. A source draws nothing itself: the layers below
name it with source_id and pick the source layer to draw. --%>
<.vector_tile_source
:if={@enabled}
id="example-vector-countries"
map_id="example-vector-map"
tiles={["https://demotiles.maplibre.org/tiles/{z}/{x}/{y}.pbf"]}
max_zoom={6}
attribution="Natural Earth, MapLibre demo tiles"
events={["source:added", "source:data", "source:removed", "source:error"]}
/>
<.fill_layer
:if={@enabled}
id="example-vector-fill"
map_id="example-vector-map"
source_id="example-vector-countries"
source_layer="countries"
paint={fill_paint(@continent)}
/>
<.line_layer
:if={@enabled}
id="example-vector-borders"
map_id="example-vector-map"
source_id="example-vector-countries"
source_layer="countries"
paint={%{"line-color" => "#7c5cd6", "line-width" => 0.6, "line-opacity" => 0.6}}
/>
<div class="grid gap-x-8 gap-y-4 border-t border-line px-4 py-4 lg:grid-cols-[1fr_auto]">
<.example_group id="example-vector-continents" label={gettext("Set assigns")}>
<.example_button
:for={continent <- continents()}
id={"example-vector-continent-#{slug(continent)}"}
pressed={@continent == continent}
phx-click="continent"
phx-value-continent={slug(continent)}
>
{continent_name(continent)}
</.example_button>
</.example_group>
<.example_group id="example-vector-toggle" label=":if" code>
<.form for={@options} id="example-vector-options" phx-change="options" class="py-1.5">
<.example_checkbox field={@options[:enabled]} label="enabled" />
</.form>
</.example_group>
</div>
<%!-- source:added, source:data and source:removed keep status current. --%>
<.example_readout values={[
continent: @continent,
enabled: @enabled,
status: @status,
data_events: @data_events
]} />
</div>