Get started

Reference

Hooks

Every derivation an element performs is published as a hook. A surface composing its own layout reads the same projection the element does. Provider, camera, layers and search hooks ship from @mountaya/elements-react. The itinerary derivations ship from @mountaya/elements-react/elements, which brings no map canvas.

No map required

Read the provider

HookReturns
useMountayaMap()the map instance, or null until the style has loaded
useMountayaClient()the client the provider holds, or null
useMountayaStrings()the resolved string table, defaults merged with your overrides
useMountayaLanguage()the active language
useMountayaControlIcons()the control icon provider in force
useMountayaUiIcons()the editor-chrome icon provider

useMountayaMap() is null before the style loads, and when there is no map at all. Every control renders disabled until it resolves.

Track the camera

import { useBearing, useCamera, useZoom } from "@mountaya/elements-react";

const camera = useCamera();
const zoom = useZoom();
const bearing = useBearing();

Each subscribes to one value and re-renders only on it. A compass reading the bearing does not re-render on pan. useCamera reports the whole pose.

Derive itinerary data

HookWhat it derives
useElevationSeriesthe distance and elevation series the profile draws
useItinerarySegmentRowsthe section rows the table states
useItineraryResourcean itinerary resolved through the provider's client
useProfileRangethe projected window a navigator drag selects
useProfileMarkerthe map marker the profile pins at the cursor
useProfilePlotthe plot geometry a custom chart needs
useWaypointCardeverything a card about one place states
useSegmentEmphasisthe highlighted segment a hover or a selection sets
useMapFeatureHoverthe itinerary feature under the pointer

useWaypointCard is the headless half of the waypoint card: a surface drawing a place its own way gets the same facts in the same order.

useItineraryResource never throws. It returns an error alongside the data and calls onError, so a surface renders its own empty state.

Read the layers manifest

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

const { terrains, classicCategories, enrichmentCategories } = useMountayaLayers();

Overlays arrive in two shapes, and the split is the layers panel's whole logic. classicCategories hold children that replace one another; enrichmentCategories hold children that stack. localizedName from @mountaya/elements/i18n resolves an entry's name in the active language.

useSearch runs the unified search and returns the row model. useSearchKeyboard wires arrow-key and enter handling over a result list. useDebouncedValue is the debounce those two use.

Next steps