# List segments and waypoints

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

Show an itinerary as a roadbook in Compose: the segment and waypoint tables, a sparkline, a place's card, each linked to a map.

The tables read an itinerary through the same cache as the [elevation profile](https://docs.mountaya.com/en/sdks/kotlin/elevation-profile.md), so the two cost one read.

## List the legs

`ItinerarySegmentTable` is a roadbook: a row per leg with its sparkline, its length, its climb and loss, and the running totals.

```kotlin
import androidx.compose.runtime.Composable
import com.mountaya.elements.ItinerarySegmentTable
import com.mountaya.geo.ItineraryResourceCache

@Composable
fun Roadbook(itineraries: ItineraryResourceCache) {
    ItinerarySegmentTable(itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache = itineraries)
}
```

- `ItinerarySegmentTable(itineraryId, cache, modifier, surface, legs, map, units, columns, highlighted, emphasisColor, markerId, markerColor, enabled, strings, onHover, onSegmentClick)`; a second form takes an `ItineraryResourceEngine`.
- `columns` takes `SegmentTableColumn` values; the default set is `defaultSegmentTableColumns`, and the altitude band, the duration and the difficulty are added as you ask (`SegmentTableColumn.entries` for all).
- A collapsed segment group is one row, its id `group:<id>`.
- Make the cache once per client: `ItineraryResourceCache(scope) { id, surface -> mountaya.studio.itineraries.getItinerary(id) { if (surface != null) this.surface = surface }.data }`.

## List the places

`ItineraryWaypointTable` lists each place, with a chip per service over the rows:

```kotlin
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import com.mountaya.client.generated.RestSchema
import com.mountaya.elements.ItineraryWaypointTable
import com.mountaya.geo.ItineraryResourceCache
import com.mountaya.geo.WaypointTableColumn

@Composable
fun Huts(itineraries: ItineraryResourceCache) {
    // The services the reader picked, kept by your app.
    val picked = remember { mutableStateOf<List<RestSchema.WaypointAmenity>>(emptyList()) }
    ItineraryWaypointTable(
        itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21",
        cache = itineraries,
        columns =
            listOf(
                WaypointTableColumn.Waypoint,
                WaypointTableColumn.Distance,
                WaypointTableColumn.Amenities,
                WaypointTableColumn.Cutoff,
            ),
        picked = picked,
    )
}
```

- `ItineraryWaypointTable(itineraryId, cache, modifier, surface, map, units, columns, picked, markerId, markerColor, formatCutoffAt, enabled, strings, onHover, onWaypointClick)`; a second form takes an `ItineraryResourceEngine`.
- A row per pass; the chips keep the places offering every service picked (`picked`, hoisted or the table's own). `columns` takes `WaypointTableColumn` values: `Waypoint`, `Profile`, `Distance`, `Elevation`, `Altitude`, `Amenities`, `Cutoff`, `Properties`; the default set is `defaultWaypointTableColumns`. There is no arrival-band column in Kotlin, and no column of your own (TypeScript's custom cells): lay out a list of your own over `itineraryWaypointRows` for that.
- The `Cutoff` column writes a time only where you hand `formatCutoffAt`.
- A cut-off is written only by the `formatCutoffAt` you hand, in the device's zone; see [services and cut-offs](https://docs.mountaya.com/en/sdks/kotlin/elevation-profile.md#places).
- The rows are Geo's, for a list of your own: `itineraryWaypointRows` and `itinerarySegmentRows`.

## Draw a sparkline

`ItinerarySparkline` draws an elevation series in a small box, with a stretch lit where you name one:

```kotlin
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.mountaya.client.generated.RestSchema
import com.mountaya.elements.ItinerarySparkline
import com.mountaya.geo.ProfileRange
import com.mountaya.geo.ResolvedItinerary
import com.mountaya.geo.buildElevationSeries

@Composable
fun TourSparkline(itinerary: RestSchema.ItineraryWithDetails) {
    val series = remember(itinerary) { buildElevationSeries(ResolvedItinerary(itinerary).geometry) }
    ItinerarySparkline(
        series,
        Modifier.size(96.dp, 24.dp),
        // Light the first half of the route.
        lit = ProfileRange(0.0, series.totalDistance / 2),
    )
}
```

- `ItinerarySparkline(series, modifier, lit, color)`: `series` is an `ElevationSeries` (`buildElevationSeries(geometry)`), `lit` a `ProfileRange(from, to)` in meters along the route, `color` a hex colour, else the tokens' accent.
- The segment table draws one per row; this is the same composable for a layout of your own.

## Show one place in a card

`WaypointCard` is a card about one place: its name, its services, when it can be used, how to reach it, its links and its photos.

```kotlin
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import com.mountaya.elements.WaypointCard
import com.mountaya.geo.ItineraryPlace

@Composable
fun HutCard(place: ItineraryPlace) {
    // Your own image loader draws each photo.
    WaypointCard(place, photo = { photo -> BasicText(photo.caption ?: photo.url) })
}
```

- `WaypointCard(place, modifier, units, formatCutoffAt, strings, photo)`. A place is an `ItineraryPlace`, from `ResolvedItinerary(itinerary).waypoints` or an `ItineraryResource.Resolved`'s itinerary.
- Each section is drawn only where the place states a line. A website or a booking page is a link only at a web address, so no script is ever opened.
- Compose's foundation loads no image: each photo is drawn by the `photo` composable you hand, and is a link where you hand none.
- Links (a phone, an email, a web address) open through Compose's `LocalUriHandler`; provide your own around the card to take them over.
- The card's facts are Geo's, for a layout of your own: `waypointCard`, `waypointSummary`, `waypointHeadline`.

## Link a table to a map

Hand each table the map's engine. A row pointed at pins a marker on the map, and a segment row lights its leg:

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

@Composable
fun RoadbookScreen(map: MapEngine, itineraries: ItineraryResourceCache) {
    Column {
        MapView(map, Modifier.fillMaxWidth().height(320.dp))
        Column(Modifier.verticalScroll(rememberScrollState())) {
            ItinerarySegmentTable(itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache = itineraries, map = map)
            ItineraryWaypointTable(itineraryId = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache = itineraries, map = map)
        }
    }
}
```

- A segment row pointed at pins the marker at the leg's end and lights the leg; a waypoint row pins the place. A leg the map's cursor hovers lights its row in the segment table (a collapsed group's row for each of its members) and pins nothing.
- `highlighted` names the row lit in place of the hover; `onHover` takes the map over, handed the row; `enabled = false` draws the table and drives nothing.
- A profile and the two tables over one map never move or take down each other's marker, and each takes down what it wrote as it leaves the composition.

## Next steps

- [Show an elevation profile](https://docs.mountaya.com/en/sdks/kotlin/elevation-profile.md): The same itinerary as a curve.
- [Turn-by-turn navigation](https://docs.mountaya.com/en/sdks/kotlin/navigation.md): Follow the itinerary with spoken guidance.
