GlassMapPanel
Extensible results panel that keeps the map behind it interactive.
- System control
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-map-panel
Drawn by the system. GlassKit configures it and leaves the glass to the system.
CaptureInstallation
spglass add glass-map-panelCopies the sources and their dependencies into your project. Set up the CLI.
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")
import SPGlassKit| Identifier | glass-map-panel |
|---|---|
| Module | SPGlassMaps |
| Kind | native-wrapper on compact widths (the system sheet); on regular widths and macOS the panel is a glassSurface floating over the map |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Maps/GlassMapPanelExample.swift |
Minimal usage
GlassMapPanel("Nearby", isPresented: $showsResults, detent: $detent) {
MapView()
} content: {
GlassMapResultList(results: results) { result in select(result) }
}Variants
| Form | When | What |
|---|---|---|
| Sheet | Compact width on iOS and iPadOS (iPhone, narrow iPad windows) | .sheet with three detents and presentationBackgroundInteraction(.enabled(upThrough: .medium)): the map stays interactive at peek and half. |
| Side panel | Regular width, and always on macOS | A glass panel over the leading edge of the map, about a third of the width (280…380 points), with collapse and close buttons. The rest of the map stays interactive. |
| Docked | Only on request, with form: .docked | A glass panel at the bottom of the map's own bounds with a grabber: drag it, or activate it, to move between the three detents. For a map that takes only part of the screen, where a system sheet would cover content that is not the map. |
| Detent | Sheet | Side panel | Docked |
|---|---|---|---|
.peek | 96 points: title only | Collapsed to the title | 96 points: grabber and title |
.half | System medium detent | Content up to 360 points high | 55 % of the map's height |
.full | System large detent (map not interactive) | Full height | The map's height less a margin |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
title | LocalizedStringKey | — | Heading of the panel. |
isPresented | Binding<Bool> | — | Whether the panel is shown. |
detent | Binding<GlassMapPanelDetent> | — | How far the panel is extended. |
isDismissable | Bool | true | When false the sheet cannot be swiped away and the side panel has no close button. |
form | GlassMapPanelForm? | nil | Forces .sheet, .side or .docked. nil picks the sheet on compact widths and the side panel elsewhere. |
map | @ViewBuilder | — | The map, any view. |
content | @ViewBuilder | — | Search field, results, details. |
GlassMapResultList(results:selection:onSelect:) is a ready-made content: rows with a tinted icon tile, a title, a subtitle and an optional trailing detail (a distance, a travel time), a tint and a checkmark on the selected row, the selection callback, and "No results" when the list is empty. GlassMapResult is id, title, subtitle, systemImage, detail.
States
Hidden, peek, half, full. In the result list: normal, selected, empty.
Advanced example
GlassMapPanel("Listings", isPresented: .constant(true), detent: $detent, isDismissable: false) {
Map(position: $engine.position, selection: $selection) { /* annotations */ }
.overlay(alignment: .topTrailing) { GlassMapControls(engine: engine).padding() }
} content: {
VStack(alignment: .leading) {
TextField("Search this area", text: $query)
.textFieldStyle(.roundedBorder)
GlassMapResultList(results: model.results(matching: query), selection: selection) { result in
selection = result.id
detent = .peek // free the map to show the selected place
}
}
}Accessibility
- The title has the header trait. The side panel's buttons are labelled "Collapse" / "Expand" and "Close".
- Result rows are buttons combining title and subtitle; the selected row has the
.isSelectedtrait and a checkmark. - The sheet keeps the system's behaviour (drag indicator, VoiceOver detent actions, keyboard avoidance).
- With Reduce Transparency the side panel becomes an opaque themed surface.
Limits
- The form is chosen from the horizontal size class and the platform (
GlassMapPanelLayout.form); it changes when an iPad window becomes compact. - A sheet is modal for assistive technologies even when the map behind it accepts touches.
- In the sheet form, while the map is interactive (
peek,half), a tap on the map does not dismiss the sheet. - The side panel is not resizable by dragging; it has three sizes.
- Dense content inside the side panel sits on glass: keep it to a list of results or short details, as the system does in Maps.
- The interaction between a live map and the sheet was compiled but not exercised in a running application during verification; the form, detent and width decisions are unit-tested.
Example
import SwiftUI
import SPGlassKit
public struct GlassMapPanelExample: GlassExample {
public static let componentID = "glass-map-panel"
@State private var isPresented = false
@State private var detent = GlassMapPanelDetent.half
@State private var selection: String?
@State private var query = ""
@State private var engine = SampleMapEngine()
/// Fictitious results.
private let results = [
GlassMapResult(id: "1", title: "Café Exemple", subtitle: "Sample data · café", systemImage: "cup.and.saucer.fill", detail: "120 m"),
GlassMapResult(id: "2", title: "Bibliothèque fictive", subtitle: "Sample data · library", systemImage: "books.vertical.fill", detail: "350 m"),
GlassMapResult(id: "3", title: "A place with a very long name that wraps over several lines in a narrow panel", subtitle: "Sample data · 1.2 km"),
GlassMapResult(id: "4", title: "مقهى تجريبي", subtitle: "Sample data · 2 km", systemImage: "cup.and.saucer"),
GlassMapResult(id: "5", title: "Parc d’essai", subtitle: "Sample data · 2.4 km", systemImage: "tree"),
]
private var filteredResults: [GlassMapResult] {
let trimmed = query.trimmingCharacters(in: .whitespaces)
return trimmed.isEmpty ? results : results.filter { $0.title.localizedStandardContains(trimmed) }
}
public init() {}
public var body: some View {
GlassMapPanel("Nearby", isPresented: $isPresented, detent: $detent) {
SampleMapBackdrop(heading: engine.heading ?? 0, zoom: engine.zoomScale)
.overlay(alignment: .topTrailing) {
// The map and its controls stay usable while the panel is open.
GlassMapControls(engine: engine)
.padding()
}
.overlay(alignment: .bottomTrailing) {
GlassButton(isPresented ? "Hide results" : "Show results", systemImage: "list.bullet") {
isPresented.toggle()
}
.padding()
}
} content: {
VStack(alignment: .leading, spacing: 12) {
TextField("Search sample places", text: $query)
.textFieldStyle(.roundedBorder)
GlassMapResultList(results: filteredResults, selection: selection) { result in
selection = result.id
detent = .peek
}
}
}
}
}
#Preview("GlassMapPanel") { GlassMapPanelExample().glassTheme(.ocean) }
Registry entry
| Identifier | glass-map-panel |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassMapPanelDetent, GlassMapPanelForm, GlassMapPanelLayout, GlassMapPanel, GlassMapResult, GlassMapResultList |
| Licence | MIT |
| Manifest | manifest.json |
Files
Maps/Maps/GlassMapPanel.swift20253 bytes · sha256 603a342b8ff6…