# List segments and waypoints

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

List an itinerary's legs and places as SwiftUI tables, draw a sparkline, and show one place in a card.

The two tables read the same itinerary the profile does, through the same cache: one request for all of them.

## List the legs

`ItinerarySegmentTable` states the legs as a roadbook: a row per leg with its sparkline, length, climb and descent.

```swift
import MountayaElements
import MountayaGeo
import SwiftUI

struct Roadbook: View {
  let itineraries: ItineraryResourceCache

  var body: some View {
    ScrollView {
      ItinerarySegmentTable(
        itineraryId: "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache: itineraries)
    }
  }
}
```

- `ItinerarySegmentTable(itineraryId:cache:surface:legs:map:units:columns:highlighted:emphasisColor:markerId:markerColor:strings:onHover:onSegmentTap:onError:)`, or `(engine:…)` over an `ItineraryResourceEngine` you hold.
- `SegmentTableColumn`: `.segment`, `.profile` (the sparkline), `.distance`, `.elevation` (climb and loss over the running totals), `.altitude` (the altitude band, as the language writes a range), `.duration`, `.difficulty`. `defaultSegmentTableColumns` is used where you name none.
- A collapsed segment group shows as one row; `onSegmentTap` hands its `group:` id.
- The rows are Geo's `itinerarySegmentRows(_:legs:stated:)`, so a screen of your own states the same figures.

## List the places

`ItineraryWaypointTable` states the places, a row per pass, with a chip per service that keeps the places offering every service picked:

```swift
import MountayaElements
import MountayaGeo
import SwiftUI

struct Places: View {
  let itineraries: ItineraryResourceCache

  var body: some View {
    ItineraryWaypointTable(
      itineraryId: "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache: itineraries,
      columns: [.waypoint, .distance, .amenities, .cutoff],
      formatCutoffAt: { cutoff in
        formatDateTime(cutoff, locale: "fr-FR", timeZone: "Europe/Paris", timeLength: .short) ?? ""
      })
  }
}
```

- `ItineraryWaypointTable(itineraryId:cache:surface:map:units:columns:picked:markerId:markerColor:formatCutoffAt:strings:onHover:onWaypointTap:onError:)`, or `(engine:…)`.
- `WaypointTableColumn`: `.waypoint`, `.profile`, `.distance`, `.elevation`, `.altitude`, `.amenities`, `.cutoff`, `.properties`. `picked:` binds the services filter (`[RestSchema.WaypointAmenity]`).
- A cut-off and a `date` field are written only by your `formatCutoffAt`; without it, none is written.

## Draw a sparkline

`ItinerarySparkline` draws a small elevation curve from a series you build with Geo:

```swift
import MountayaClient
import MountayaElements
import MountayaGeo
import SwiftUI

struct TourSparkline: View {
  let itinerary: RestSchema.ItineraryWithDetails

  var body: some View {
    ItinerarySparkline(series: buildElevationSeries(ResolvedItinerary(itinerary).geometry))
      .frame(width: 120, height: 32)
  }
}
```

- `ItinerarySparkline(series:lit:color:)`: `lit` is a `ProfileRange` drawn emphasized, `color` a hex string over the token's.
- `buildElevationSeries(_:maxPoints:)` reads a `GeoJSONGeometry?` (a line, a multi-line, a collection) into one distance axis, down-sampled to `maxProfilePoints` unless you pass another.

## Show one place in a card

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

```swift
import MountayaElements
import MountayaGeo
import SwiftUI

struct PlaceSheet: View {
  let place: ItineraryPlace

  var body: some View {
    ScrollView {
      WaypointCard(
        place: place,
        formatCutoffAt: { cutoff in
          formatDateTime(cutoff, locale: "fr-FR", timeZone: "Europe/Paris", timeLength: .short) ?? ""
        })
    }
  }
}
```

The places of an itinerary are `ResolvedItinerary(itinerary).waypoints`.

- `WaypointCard(place:units:formatCutoffAt:strings:)`, and `(…photo:)` with a `@ViewBuilder` that draws each `WaypointDetails.Photo` with your own image loader; without it, `AsyncImage` loads a photo at a web address.
- 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 tapped. A link opens through SwiftUI's `openURL` action: state your own around the card to take every link over.
- The card's facts are Geo's `waypointCard(_:scope:units:formatCutoffAt:)`.

## Link a table to a map

Hand a table your map. A row pointed at pins a marker on the map, and a leg the map's cursor is over lights its row:

```swift
import MountayaElements
import MountayaGeo
import SwiftUI

struct TablesBesideMap: View {
  let map: MapEngine
  let itineraries: ItineraryResourceCache

  var body: some View {
    VStack(spacing: 0) {
      MapView(map)
      ItinerarySegmentTable(
        itineraryId: "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21", cache: itineraries, map: map)
    }
  }
}
```

- A segment row pins the marker at the leg's end and lights its leg; a waypoint row pins it at the place. A collapsed group's row lights for each of its members. `highlighted` names the row to light instead.
- Each element pins under its own id (`segmentTableCursorMarkerId`, `waypointTableCursorMarkerId`), so a profile and two tables over one map never take down each other's marker, and each removes what it wrote as it leaves.
- `onHover` takes the map over, handed the row. `.disabled(true)` draws a table and drives nothing.

## Next steps

- [Geo without a map](https://docs.mountaya.com/en/sdks/swift/geo.md): The same figures in a screen of your own.
- [Turn-by-turn navigation](https://docs.mountaya.com/en/sdks/swift/navigation.md): Follow the itinerary on the device.
