Get started

Show itinerary data

Show an elevation profile

ItineraryProfile draws an itinerary's elevation from one request. It needs no map.

One request No map required

Draw the curve

Name an itinerary and give the provider a client:

import { ItineraryProfile } from "@mountaya/elements-react/elements";
import { MountayaElementsProvider } from "@mountaya/elements-react/headless";
import "@mountaya/elements-react/styles.css";

<MountayaElementsProvider client={client}>
  <ItineraryProfile itineraryId={itineraryId} stats={["distance", "ascent", "descent"]} />
</MountayaElementsProvider>;

Both imports skip the map renderer, so a page with no map loads no MapLibre. Install lists the packages, and Hooks the derivations behind the chart.

Turn on the axis, sections and tooltip

Everything past the curve is opt-in:

<ItineraryProfile
  axis={{ x: { ticks: 8 }, y: true }}
  curveColors={{ mode: "slope" }}
  itineraryId={itineraryId}
  navigator
  sections
  tooltip
/>;

curveColors colours the curve by gradient, by your own classes, or by spans you pass.

Show services and cut-offs

Where waypoints declare services, the profile stacks them as badges above each pin. Pass formatCutoffAt to print each place's cut-off time:

<ItineraryProfile
  amenities={{ max: 3 }}
  formatCutoffAt={(iso: string) =>
    new Intl.DateTimeFormat("fr-FR", {
      hour: "2-digit",
      minute: "2-digit",
      timeZone: "Europe/Paris",
    }).format(new Date(iso))
  }
  itineraryId={itineraryId}
/>;

Link the curve to a map

Put a map on the provider and the profile follows it:

<MountayaElementsProvider client={client} map={map}>
  <MapView client={client} onReady={setMap} terrain="topo" />
  <ItineraryProfile axis itineraryId={itineraryId} sections tooltip />
</MountayaElementsProvider>

Hovering the curve pins the place on the map. Hovering the route tints that leg on the chart.

Next steps

Last updated