# Controls and panels

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

Float the Mountaya map controls over a Compose map, pick each control, open the layers, points-of-interest and preferences panels, and offer the time slider.

`MapControls` floats the map's controls in one of its corners, inside the map's safe area and clear of the watermark. Each control drives the map unless you hand it a handler.

## Add the control stack

```kotlin
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.mountaya.elements.MapControls
import com.mountaya.elements.MapEngine
import com.mountaya.elements.MapView

@Composable
fun MapWithControls(map: MapEngine) {
    Box(Modifier.fillMaxSize()) {
        MapView(map, Modifier.fillMaxSize())
        // Zoom, compass, layers and preferences show by default.
        MapControls(map, pois = true, geolocate = true)
    }
}
```

- From the top, the stack reads the zoom pair, the layers, points-of-interest and preferences toggles as one group, your own controls, geolocate and the compass. It sits top right unless you name another `corner` (`MapCorner`), as the reader sees it whichever way the text runs.
- Each flag is a plain boolean with a fixed default: `zoom`, `compass`, `layers` and `preferences` default to `true`; `pois`, `geolocate` and `offersTime` to `false`. None is read from your organization.
- `enabled = false` shuts every control, yours among them. A toggle opens its panel in place of any other, so one panel is open at a time; hoist which one with `openPanel: MutableState<MapPanel?>`, and the units with `unitPreferences: MutableState<UnitPreferences>`.
- Every button is 48 dp across, and draws a 2 dp ring in the tokens' `focus-ring` while it holds the keyboard's focus. Zoom in is disabled at the camera's zoom ceiling, zoom out at its floor.
- A panel the stack opens is laid out as the embed's: 340 dp wide (the width its corner leaves on a map no wider than 576 dp), no taller than the map leaves below its top, under a title row that stays while its sections scroll.

## Pick the control for the job

Put your own controls in the stack's trailing block, beside the built-in ones:

```kotlin
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import com.mountaya.elements.DownloadControl
import com.mountaya.elements.MapControls
import com.mountaya.elements.MapEngine
import com.mountaya.elements.MapPanel
import com.mountaya.elements.PanelControl

@Composable
fun StackWithExtras(map: MapEngine, onDownload: () -> Unit) {
    MapControls(map) {
        DownloadControl(onClick = onDownload)
        PanelControl(MapPanel("filters"), label = "Filters", glyph = "preferences", help = "Huts only") {
            BasicText("Huts only")
        }
    }
}
```

- The controls, each usable on its own: `ZoomControl(map, onZoomInClick, onZoomOutClick)`, `CompassControl(map, onClick)`, `GeolocateControl(map, isLocating, onClick, onError)`, `DownloadControl(onClick)`, `DirectionsControl(onClick)`, and `PanelControl(panel, label, glyph, help) { content }`, a toggle that opens a panel of yours. Download and directions drive nothing of the map's, so their `onClick` is required.
- A handler you pass stands in for the control's default; leave it out and the control drives the map.
- Geolocate never asks for access: it reads the standing permission, says location is blocked while it answers refused, and is drawn in the accent until each fix it asked for settles.
- Every control, panel and the stack take `strings`, words by path (`controls.zoomIn`) that stand over the scope's for that composable and everything it draws; a control's own stand over the stack's.
- The words come from the scope `MountayaScope(statement, scheme)` nests, and the colours from `LocalMountayaTokens`, under the colour scheme in force (`ThemeScheme.Dark`, else the configuration's night mode).

## Choose terrains, points of interest and units

The stack opens three panels. Each can also stand on its own:

```kotlin
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import com.mountaya.elements.LayersPanel
import com.mountaya.elements.MapEngine
import com.mountaya.elements.PoiPanel
import com.mountaya.elements.PreferencesPanel
import com.mountaya.client.generated.RestSchema
import com.mountaya.geo.LayersSelectionEngine
import com.mountaya.geo.PoiPanelGroup
import com.mountaya.geo.UnitPreferences

@Composable
fun SidePanels(map: MapEngine) {
    val scope = rememberCoroutineScope()
    val selection = remember(map) { LayersSelectionEngine(scope, map) }
    var units by remember { mutableStateOf(UnitPreferences("fr", length = RestSchema.UnitLength.Metric)) }
    LayersPanel(selection)
    // The Mountaya app's own water group, one row over the drinking-water layer.
    PoiPanel(map, groups = listOf(PoiPanelGroup("water", "Water", listOf("drinking-water"))))
    PreferencesPanel(units, onPreferencesChange = { units = it }, map = map)
}
```

- `LayersPanel(selection)` lists the catalogue as `LayersSelectionEngine` holds it, which drives the map, in four sections: the base maps as picture cards, the enrichments as switches, the classic overlays as picture cards one category at a time behind a segmented switch, and the time where you offer it. `thumbnail = { choice, slug -> painter }` hands a card its picture; a card with none shows its name. `isLocked` and `onLockedClick` mark a layer your plan does not include.
- `PoiPanel(map, keys, groups, activeGroups, labels, minZoom, showsAllToggle)` offers the concepts the map draws; `PoiPanelGroup(id, label, keys, glyph)` groups several under one switch; a group's `keys` are the points-of-interest layer's own keys, as the layers catalogue names them (`drinking-water`), the group `water` being the one the Mountaya app shows.
- `PreferencesPanel(preferences, onPreferencesChange, map)` hands you your `UnitPreferences` back with one preference changed (length `Metric` or `Imperial`, pace, slope, temperature), and relabels the map for a language where you pass `map`.
- Layer cards sit three to a row, preferences two.

## Move through time

Show the snow depth, and offer the time slider in the layers panel. The map draws the overlay for the instant the reader picks:

```kotlin
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import com.mountaya.elements.MapControls
import com.mountaya.elements.MapEngine

@Composable
fun SnowDepthControls(map: MapEngine) {
    LaunchedEffect(map) { map.setOverlay("snow-depth") }
    MapControls(map, offersTime = true)
}
```

`map.setInstant(instant)` pins an instant from your own code, and `null` goes back to now.

- `offersTime = true` lists the time slider in the layers panel: a track ticked every day and labelled at -2d, now, +2d and +5d, one stop an hour from 71 hours back to 144 ahead, filled from now to its thumb. Its release pins the instant of its stop through the selection's `setInstant`, or none on now.
- A classic overlay the server stamps with a time is drawn for the instant pinned, its tiles asked again as the pin moves and kept over a base-map switch. Enrichments are never stamped. With none pinned, the map draws the overlay's own addresses, which the Tile API answers for the moment each tile arrives.
- Offer it only where your organization's overlay time control allows it: the Tile API refuses a publishable key or a share token a stamped tile asked more than 15 minutes from now.
- The slider reads the clock `LocalMountayaClock` provides (the system's unless you provide another, so a replay moves its window) and writes its moment in the scope's locale and the device's time zone.
- The slider's rules are Geo's: `timeSliderWindow(now)`, `timeSliderTicks`, `timeSliderRelease(window, value)` and `timeSliderReadout(window, value)`. A selection target of your own implements `LayersSelectionTarget.setInstant`.

## Next steps

- [Search](https://docs.mountaya.com/en/sdks/kotlin/search.md): A search box over the map.
- [Show an elevation profile](https://docs.mountaya.com/en/sdks/kotlin/elevation-profile.md): An itinerary's elevation, linked to the map.
