# Show an elevation profile

> Canonical URL: https://docs.mountaya.com/en/sdks/kotlin/elevation-profile/
> Last updated: 2026-11-27
> Rules for agents: https://docs.mountaya.com/llms.txt#rules-for-agents

Draw an itinerary's elevation profile in Compose with ItineraryProfile, with its axis, sections, tooltip, services and cut-offs, linked to a map.

`ItineraryProfile` draws an itinerary's elevation from one read. It needs no map, and links to one when you hand it.

## Draw the curve

Make one cache per client, and name the itinerary:

```kotlin
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.mountaya.client.Mountaya
import com.mountaya.elements.ItineraryProfile
import com.mountaya.geo.ItineraryResourceCache
import com.mountaya.geo.StatStripStat

@Composable
fun TourProfile(mountaya: Mountaya) {
    val scope = rememberCoroutineScope()
    // Every element reading through one cache shares its reads.
    val itineraries =
        remember {
            ItineraryResourceCache(scope) { id, surface ->
                mountaya.studio.itineraries.getItinerary(id) { if (surface != null) this.surface = surface }.data
            }
        }
    ItineraryProfile(
        itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21",
        cache = itineraries,
        modifier = Modifier.fillMaxWidth().height(220.dp),
        stats = listOf(StatStripStat.Distance, StatStripStat.Ascent, StatStripStat.Descent),
    )
}
```

The cache reads through your client, so the profile never calls the network itself.

- `ItineraryProfile(itineraryId, cache, modifier, surface, legs, map, units, stats, coloring, bands, parts, anchor, window, highlighted, emphasisColor, markerId, markerColor, formatCutoffAt, enabled, strings, onHover, onWaypointClick, onSegmentClick, onError)`. A second form takes an `ItineraryResourceEngine` of yours in place of the id, the cache and the surface, which it reads and never closes.
- `ItineraryResourceCache(scope) { id, surface -> … }` is made once per client, its reads run in your scope; `invalidate(id)` makes every element over that itinerary read it again, after your app saved it. When the signed-in member changes, make a new cache.
- The stat strip over the chart states `stats` (distance, ascent and descent by default). Units come from `units`, else the scope's.
- The elevation is the third coordinate of each position: a vertex with none advances the distance and draws no point.
- The profile, `ItinerarySegmentTable`, `ItineraryWaypointTable`, `ItinerarySparkline` and `WaypointCard` are Android only. The rules under them are Geo's and run everywhere: `buildElevationSeries`, `profileTotals`, `profilePolyline`, `distanceTicks` (see [geo](https://docs.mountaya.com/en/sdks/kotlin/geo.md#elevation)).
- The distance scale and the chips grow with the reader's font scale rather than clipping. A scrub draws the cursor again and not the curve.

## Turn on the axis, sections and tooltip

Everything past the curve and its services is opt-in, through `parts`:

```kotlin
import androidx.compose.runtime.Composable
import com.mountaya.elements.ItineraryProfile
import com.mountaya.elements.ProfileColoring
import com.mountaya.elements.ProfilePart
import com.mountaya.geo.ItineraryResourceCache
import com.mountaya.geo.slopeBuckets

@Composable
fun DetailedProfile(itineraries: ItineraryResourceCache) {
    ItineraryProfile(
        itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21",
        cache = itineraries,
        parts =
            setOf(
                ProfilePart.Amenities,
                ProfilePart.ElevationAxis,
                ProfilePart.DistanceAxis,
                ProfilePart.Navigator,
                ProfilePart.Sections,
                ProfilePart.Tooltip,
            ),
        // Colour the curve by gradient.
        coloring = ProfileColoring.Slope(slopeBuckets),
    )
}
```

- `ProfilePart`: `Amenities` (the default set, `ProfilePart.standard`), `Sections` (a chip per leg under the chart), `Tooltip` (the card at the cursor), `ElevationAxis`, `DistanceAxis` (place names thinned until each label clears its neighbours) and `Navigator` (a window over the range shown, its range hoisted through `window: MutableState<ProfileRange?>`).
- `coloring`: `ProfileColoring.Plain` (the default), `Slope(buckets)` by gradient, `Classes(…)` by your own classes, or `Stretches(…)` by spans you hand. `bands` adds a band strip of `ProfileClass` values.
- `anchor`: `ProfileAnchor.Route` (the default) or `Window`, which scales the elevation axis to the window shown.
- A leg's chip is a button where you pass `onSegmentClick`, handed the leg's id (a collapsed group's `group:<id>`); it writes nothing to the map.
- A named waypoint ends a section; an unnamed one is a pin and nothing more.

## Show services and cut-offs

Places that declare services show them as badges above their pins. Hand `formatCutoffAt` to write each place's cut-off time:

```kotlin
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import com.mountaya.elements.ItineraryProfile
import com.mountaya.geo.ItineraryResourceCache
import com.mountaya.geo.TimeLength
import com.mountaya.geo.formatDateTime
import kotlin.time.Instant

@Composable
fun ProfileWithCutoffs(itineraries: ItineraryResourceCache) {
    // Each cut-off in French, on the Alps' clock.
    val writeCutoff = remember { cutoffWriter("fr-FR", "Europe/Paris") }
    ItineraryProfile(
        itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21",
        cache = itineraries,
        formatCutoffAt = writeCutoff,
    )
}

// Null where the platform knows no zone of that name, so no cut-off is written.
fun cutoffWriter(language: String, zone: String): ((Instant) -> String)? {
    formatDateTime(Instant.fromEpochSeconds(0), language, zone) ?: return null
    return { cutoff ->
        formatDateTime(cutoff, language, zone, timeLength = TimeLength.Short) ?: error("$zone was known when the writer was made.")
    }
}
```

- The data is the switch for badges: a profile whose places declare no service draws none. `ProfilePart.Amenities` is on by default; leave it out of `parts` to hide the badges. Kotlin has no cap on a deep stack of badges (TypeScript's `amenities={{ max: 3 }}`): every service is stacked.
- A cut-off written for a fixed zone, `Europe/Paris` here, reads the same wherever the reader is; `TimeZone.getDefault().id` writes it on the device's clock instead.
- A cut-off, and a `date` field, are written only by the `formatCutoffAt` you hand, since the time zone is your app's; an element handed none writes neither. Write one with `formatDateTime` in the device's zone, and hand none where the platform knows no zone of that name (`formatDateTime` answers null): never the instant in UTC as `Instant.toString()` writes it.
- `ItineraryWaypointTable` and `WaypointCard` take the same `formatCutoffAt`.

## Link the curve to a map

Hand the profile the map's engine. Scrubbing the curve pins a marker on the map and lights the leg under it:

```kotlin
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.mountaya.elements.ItineraryProfile
import com.mountaya.elements.MapEngine
import com.mountaya.elements.MapView
import com.mountaya.elements.ProfilePart
import com.mountaya.geo.ItineraryResourceCache

@Composable
fun MapAndProfile(map: MapEngine, itineraries: ItineraryResourceCache) {
    Column {
        MapView(map, Modifier.fillMaxWidth().height(320.dp))
        ItineraryProfile(
            itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21",
            cache = itineraries,
            modifier = Modifier.fillMaxWidth().height(220.dp),
            map = map,
            parts = setOf(ProfilePart.Amenities, ProfilePart.ElevationAxis, ProfilePart.Sections, ProfilePart.Tooltip),
        )
    }
}
```

- A scrub pins the cursor marker on the map at the sample (`markerId`, `markerColor`) and lights the leg under it (`emphasisColor`), the later leg at the meter two share. A leg the map's cursor hovers lights on the chart.
- `onHover` takes both directions over, handed the sample; `highlighted` names the leg lit in its place. `enabled = false` draws the profile and drives nothing.
- A profile and the two tables over one map never move or take down each other's marker, each pinning under an id of its own, and each takes down what it wrote as it leaves the composition. Over one cache, they cost one read.
- The same marker and emphasis are functions of `mountaya-elements` over a `MapEngine`, for views of your own: `showCursorMarker`, `hideCursorMarker`, `writeLegEmphasis`.

## Next steps

- [List segments and waypoints](https://docs.mountaya.com/en/sdks/kotlin/tables.md): The same itinerary read as rows.
- [Geo without a map](https://docs.mountaya.com/en/sdks/kotlin/geo.md): The elevation series and its figures, with no UI.
