raster_tile_source
StableAdds raster image tiles for a raster layer to draw.
tiles
- @imagery
- day
- @status
- waiting
- @data_events
- 0
- @failed_tile
- nil
<div id="raster-tile-source-example">
<.example_frame
error={@map_error}
error_id="example-raster-map-error"
hosts={["gibs.earthdata.nasa.gov"]}
>
<%!-- A blank style, in both themes: the raster layer below is all the
map draws. --%>
<.map
id="example-raster-map"
center={[10, 30]}
zoom={1.5}
max_zoom={8}
style={blank_style()}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<%!-- NASA's imagery is public domain; the attribution credits the service. --%>
<.raster_tile_source
id="example-raster-tiles"
map_id="example-raster-map"
tiles={tiles(@imagery)}
tile_size={256}
max_zoom={8}
attribution="Imagery: NASA EOSDIS GIBS"
events={["source:added", "source:data", "source:error"]}
/>
<.raster_layer
id="example-raster-tiles-layer"
map_id="example-raster-map"
source_id="example-raster-tiles"
/>
<div class="border-t border-line px-4 py-4">
<%!-- A new imagery changes the tiles; the source keeps its place. --%>
<.example_group id="example-raster-imageries" label="tiles" code>
<.example_button
:for={imagery <- imageries()}
id={"example-raster-imagery-#{imagery}"}
pressed={@imagery == imagery}
phx-click="imagery"
phx-value-imagery={imagery}
>
{imagery_name(imagery)}
</.example_button>
</.example_group>
</div>
<%!-- source:added and source:data keep status current; source:error
names the tile that failed, if any. --%>
<.example_readout values={[
imagery: @imagery,
status: @status,
data_events: @data_events,
failed_tile: @failed_tile || "nil"
]} />
</div>
The events this component sends to the LiveView, as the library documents them. Each arrives in handle_event/3. Use the preview; the last payload of each event the example receives appears here. A component sends only the events its events attribute names, so the example receives those its LiveView handles.
-
source:added
Fired once, with
source_id, the first time the source is on the map (not again when a style change, or a map rendered again with the same id, puts it back)Not received yet.
-
source:removed
Fired, with
source_id, once the source is gone after the component is removed, ifsource:addedwas firedNot received yet.
-
source:data
Fired for each of MapLibre's
sourcedataloadingandsourcedataevents about this source: its data is loading, or has loaded or changedNot received yet.
-
source:error
Fired when MapLibre reports an error loading the source or one of its tiles, or fails to add or replace the source
Not received yet.