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>
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.