Skip to content

raster_dem_source

Stable

Adds elevation tiles for hillshading and 3D terrain.

Set assigns

@place
alps
@status
waiting
@data_events
0
lib/maplibrex_demo_web/examples/raster_dem_source_example.html.heex
<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>