raster_dem_source
StableAdds elevation tiles for hillshading and 3D terrain.
Set assigns
- @place
- alps
- @status
- waiting
- @data_events
- 0
<div id="raster-dem-source-example">
<.example_frame
error={@map_error}
error_id="example-dem-map-error"
hosts={["tiles.openfreemap.org", "tiles.mapterhorn.com"]}
>
<.map
id="example-dem-map"
center={@center}
zoom={10}
style={basemap(@theme)}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<%!-- Elevation from Mapterhorn's public TileJSON. A DEM source draws
nothing itself: the hillshade layer below makes it visible. --%>
<.raster_dem_source
id="example-dem"
map_id="example-dem-map"
url="https://tiles.mapterhorn.com/tilejson.json"
events={["source:added", "source:data", "source:error"]}
/>
<.hillshade_layer id="example-dem-hillshade" map_id="example-dem-map" source_id="example-dem" />
<div class="border-t border-line px-4 py-4">
<%!-- A new centre moves the map; the source loads the tiles in view. --%>
<.example_group id="example-dem-places" label={gettext("Set assigns")}>
<.example_button
:for={{id, name} <- places()}
id={"example-dem-place-#{id}"}
pressed={@place == id}
phx-click="go"
phx-value-place={id}
>
{name}
</.example_button>
</.example_group>
</div>
<%!-- source:added and source:data keep status and data_events current. --%>
<.example_readout values={[place: @place, status: @status, data_events: @data_events]} />
</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 (either url or tiles must be provided) |
| tiles | list |
nil
|
List of tile URL templates |
| tile_size | integer |
nil
|
Size of tiles in pixels (default: 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] |
| encoding | string |
nil
|
Encoding format: "mapbox" (default) or "terrarium" |
| volatile | boolean |
false
|
Whether data should be cached (default: false) |
| events | any |
[]
|
a list of event names, or :all
|