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>
Generated from the component's definition in the library, so it always matches the version this demo runs.
| Attribute | Type | Default | Description |
|---|---|---|---|
| id required | string | — | Unique identifier for the source |
| map_id required | string | — | ID of the map to attach to |
| url | string |
nil
|
TileJSON URL, or a pmtiles:// URL (see "PMTiles" in the module documentation) (either url or tiles must be provided)
|
| tiles | list |
nil
|
List of tile URL templates (e.g., ["https://a.tile.com/{z}/{x}/{y}.png"]) |
| tile_size | integer |
nil
|
Size of tiles in pixels (default: 512, common values: 256, 512) |
| min_zoom | integer |
nil
|
Minimum zoom level (default: 0) |
| max_zoom | integer |
nil
|
Maximum zoom level (default: 22) |
| attribution | string |
nil
|
Attribution text |
| bounds | list |
nil
|
Geographic bounds [west, south, east, north] |
| scheme | string |
nil
|
Tile scheme: "xyz" (default) or "tms" |
| tms | boolean |
false
|
true for tiles in the TMS scheme, the same as scheme="tms" (default: false). A scheme given too wins over it
|
| volatile | boolean |
false
|
Whether data should be cached (default: false) |
| events | any |
[]
|
a list of event names, or :all
|