Get started
Show itinerary data

List segments and waypoints

List segments and waypoints

ItinerarySegmentTable lists the legs of an itinerary. ItineraryWaypointTable lists its places, and WaypointCard opens one place in full. None needs a map.

No map required

All three share the elevation profile's cache, so three elements naming one itinerary cost one request. Install lists the packages.

List the legs

import { ItinerarySegmentTable } from "@mountaya/elements-react/elements";

<ItinerarySegmentTable itineraryId={itineraryId} />;

A row is a segment, in the order the itinerary runs. Each measuring cell states the leg's figure, then the running total.

Add a column of your own

Custom columns go in the same ordered list as the built-in ones, so you can reorder, drop and interleave them:

<ItinerarySegmentTable
  columns={[
    "segment",
    "profile",
    "distance",
    "elevation",
    {
      align: "end",
      cell: (row) => cutoffAt(row.id),
      header: "Cut-off time",
      id: "cutoff",
    },
  ]}
  itineraryId={itineraryId}
/>;

List the places

import { ItineraryWaypointTable } from "@mountaya/elements-react/elements";

<ItineraryWaypointTable
  columns={["waypoint", "distance", "amenities", "cutoff"]}
  itineraryId={itineraryId}
/>;
ColumnStates
waypointThe place's icon and name
profileThe whole itinerary, with the stretch that reaches the place lit
distanceMeters from the start
elevationClimb and loss since the previous place
altitudeThe altitude at the place
amenitiesThe services the place offers
cutoffWhen the place must be left
arrivalThe fastest to slowest arrival band
propertiesThe author's own fields

Filter the places by service

Pass onFilterChange and the toolbar shows a chip per service the itinerary offers:

import { useState } from "react";

import { ItineraryWaypointTable } from "@mountaya/elements-react/elements";

const Course = () => {
  const [filter, setFilter] = useState<readonly string[]>([]);

  return (
    <ItineraryWaypointTable filter={filter} itineraryId={itineraryId} onFilterChange={setFilter} />
  );
};

Selecting several services keeps the places that offer all of them.

Show one place in a card

WaypointCard states what a place offers, when it can be used, and how to reach it:

import { itineraryWaypoint } from "@mountaya/elements/data";
import { WaypointCard } from "@mountaya/elements-react/elements";

const mapped = itineraryWaypoint(record);

mapped === null ? null : <WaypointCard waypoint={mapped} />;

itineraryWaypoint maps a stored waypoint to what the card draws. For your own markup, useWaypointCard({ waypoint }) returns the same facts and renders nothing.

Link a table to a map

Put a map on the provider and the tables follow it:

<MountayaElementsProvider client={client} map={map}>
  <MapView client={client} onReady={setMap} terrain="topo" />
  <ItinerarySegmentTable itineraryId={itineraryId} />
</MountayaElementsProvider>

Hovering a row lights that leg on the route. Hovering the route lights the row.

Next steps

Last updated