GlassLocationButton
| Identifier | glass-location-button |
| Module | SPGlassMaps |
| Kind | custom-glass — a round interactive glassSurface |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Maps/GlassLocationButtonExample.swift |
Minimal usage
swift
GlassLocationButton(state: model.locationState) { model.locationButtonTapped() }Variants
| State | Symbol | Label | Enabled |
|---|---|---|---|
.idle |
location |
"Show my location" | yes |
.locating |
location, pulsing |
"Finding your location" | yes |
.following |
location.fill, primary colour |
"Following your location" | yes |
.denied |
location.slash |
"Location access denied" | yes — the host can explain or open Settings |
.unavailable |
location.slash |
"Location unavailable" | no |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
state |
GlassLocationState |
— | State reported by the host. |
hint |
String? |
nil |
Explanation read as the accessibility hint and shown as the tooltip on macOS. |
size |
GlassControlSize |
.regular |
Size of the control. |
action |
@MainActor () -> Void |
— | Called on activation. |
The mapping from state to symbol, label and enabled flag is GlassLocationPresentation(state), a value type usable without the view.
States
See the table above. The pulse of .locating is a symbol effect that stops with Reduce Motion; the state is then conveyed by the label alone.
Advanced example
swift
@MainActor @Observable
final class LocationModel: NSObject, CLLocationManagerDelegate {
private let manager = CLLocationManager()
private(set) var state = GlassLocationState.idle
func buttonTapped() {
switch manager.authorizationStatus {
case .notDetermined: manager.requestWhenInUseAuthorization() // the host asks, never the button
case .denied: openSettings()
case .restricted: state = .unavailable
default: state = .locating; manager.startUpdatingLocation()
}
}
// delegate callbacks update `state` to .following, .denied, …
}
GlassLocationButton(
state: model.state,
hint: model.state == .denied ? "Opens Settings to allow location access" : nil
) { model.buttonTapped() }Accessibility
- The label is the state itself ("Location access denied"), so VoiceOver announces it without relying on the symbol.
- Denied and unavailable use a slashed symbol and their own label — never colour alone.
hintbecomes the accessibility hint; while locating the button has the "updates frequently" trait.- The target is at least 44 points on iOS and iPadOS.
Limits
- The button never requests the location permission, never reads a position and does not import Core Location: all of that is the host's code.
- There is no visible text next to the symbol; put a banner or an alert in the host if the denied state needs a visible explanation.