raster_layer
StableShows raster tiles, an image or a video from a source.
- @opacity
- 0.7
- @saturation
- 0
- @hue
- 0
<div id="raster-layer-example">
<.example_frame
error={@map_error}
error_id="example-raster-layer-map-error"
hosts={["tiles.openfreemap.org", "gibs.earthdata.nasa.gov"]}
>
<.map
id="example-raster-layer-map"
center={[10, 30]}
zoom={1.6}
style={basemap(@theme)}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<%!-- NASA's imagery is public domain; the attribution credits the service.
GIBS orders the tile path {z}/{y}/{x}. --%>
<.raster_tile_source
id="example-raster-layer-tiles"
map_id="example-raster-layer-map"
tiles={[
"https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/BlueMarble_ShadedRelief_Bathymetry/default/GoogleMapsCompatible_Level8/{z}/{y}/{x}.jpeg"
]}
tile_size={256}
max_zoom={8}
attribution="Imagery: NASA EOSDIS GIBS"
events={["source:error"]}
/>
<.raster_layer
id="example-raster-layer-imagery"
map_id="example-raster-layer-map"
source_id="example-raster-layer-tiles"
paint={
%{
"raster-opacity" => @opacity,
"raster-saturation" => @saturation,
"raster-hue-rotate" => @hue
}
}
/>
<div class="border-t border-line px-4 py-4">
<.form
for={@options}
id="example-raster-layer-options"
phx-change="options"
class="grid w-full gap-4 sm:grid-cols-3"
>
<.example_range
field={@options[:opacity]}
label="raster-opacity"
min="0"
max="1"
step="0.05"
/>
<.example_range
field={@options[:saturation]}
label="raster-saturation"
min="-1"
max="1"
step="0.1"
/>
<.example_range field={@options[:hue]} label="raster-hue-rotate" min="0" max="360" step="5" />
</.form>
</div>
<.example_readout values={[opacity: @opacity, saturation: @saturation, hue: @hue]} />
</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 layer |
| map_id required | string | — | ID of the map to attach to |
| source_id required | string | — | ID of the raster data source |
| paint | map |
%{}
|
Paint properties (raster-opacity, raster-hue-rotate, etc.) |
| layout | map |
%{}
|
Layout properties (visibility) |
| min_zoom | integer |
nil
|
Minimum zoom level for layer visibility |
| max_zoom | integer |
nil
|
Maximum zoom level for layer visibility |
| before_id | string |
nil
|
ID of layer to insert this layer before |
| events | any |
[]
|
a list of event names, or :all
|