hillshade_layer
StableShades relief from a raster DEM source.
Set assigns
:if
- @look
- plain
- @visible
- true
- @on_map
- false
<div id="hillshade-layer-example">
<.example_frame
error={@map_error}
error_id="example-hillshade-map-error"
hosts={["tiles.openfreemap.org", "tiles.mapterhorn.com"]}
>
<.map
id="example-hillshade-map"
center={[7.6586, 45.9763]}
zoom={11}
style={basemap(@theme)}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<.raster_dem_source
id="example-hillshade-dem"
map_id="example-hillshade-map"
url="https://tiles.mapterhorn.com/tilejson.json"
events={["source:error"]}
/>
<%!-- A new look is a new paint: the layer repaints in place. --%>
<.hillshade_layer
:if={@visible}
id="example-hillshade-layer"
map_id="example-hillshade-map"
source_id="example-hillshade-dem"
paint={paint(@look)}
events={["layer:added", "layer:removed"]}
/>
<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-hillshade-looks" label={gettext("Set assigns")}>
<.example_button
:for={look <- looks()}
id={"example-hillshade-look-#{look}"}
code
pressed={@look == look}
phx-click="look"
phx-value-look={look}
>
{look}
</.example_button>
</.example_group>
<.example_group id="example-hillshade-toggle" label=":if" code>
<.form for={@options} id="example-hillshade-options" phx-change="options" class="py-1.5">
<.example_checkbox field={@options[:visible]} label="visible" />
</.form>
</.example_group>
</div>
<%!-- layer:added and layer:removed keep on_map current. --%>
<.example_readout values={[look: @look, visible: @visible, on_map: @on_map]} />
</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-dem source |
| source_layer | string |
nil
|
Layer in the source (for vector tiles, optional) |
| paint | map |
%{}
|
Paint properties for hillshading effect |
| 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
|