SP GlassKit1.1.0

GlassMapPin

Configurable marker with selection and an accessible label; clustering is left to the map engine.

  • Content
  • iOS 26 · iPadOS 26 · macOS 26
  • Version 1.1.0
  • glass-map-pin

Content on an opaque, readable surface. Glass is kept for controls.

GlassMapPin running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-map-pin

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-map-pin
ModuleSPGlassMaps
Kindcontent-component — an opaque tinted pin with a tail; no glass
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Maps/GlassMapPinExample.swift

Minimal usage

Swift
GlassMapPin(.symbol("fork.knife"), title: "Chez Sample")

Variants

VariantUse
.symbol(name)An SF Symbol in the marker. Always give a title: it is the accessibility label.
.text(string)A short text (price, letter, rank), cut after 4 characters.
init(clusterCount:cap:)A cluster marker: a disc with a halo and no tail, showing the localised count, or the cap followed by "+" ("99+").
isSelected: trueLarger pin, thicker outline and the title on a chip under the tip.
tint:Any colour role of the theme (.primary, .accent, .success, .warning, …). Text and symbol take the legible colour for that fill.

Parameters

ParameterTypeDefaultMeaning
contentGlassMapPinContent—What the marker shows.
titleString?nilName of the place: accessibility label, and visible label when selected.
tintGlassColorToken.primary (.secondary for clusters)Colour role of the marker.
isSelectedBoolfalseSelected appearance and trait.
clusterCountInt—Number of places the cluster stands for; negative values count as 0.
capInt99Largest count shown as a number.

Anchoring. The tip of the tail is the bottom centre of the view in every state: anchor the annotation there (Annotation(…, anchor: .bottom) in MapKit). The title of a selected pin hangs under the tip without taking part in the layout, so selecting a pin does not move it. A cluster has no tail: anchor it at its centre. GlassMapPinShape (the capsule with its tail) is public for hosts that draw their own marker.

States

Normal and selected. The pin has no pressed state of its own: it is a plain view, and the tap belongs to the annotation of the map engine (or to a Button wrapped around it).

Advanced example

Swift
// MapKit; any other engine hosts the same view in its own annotation type.
Map(position: $engine.position, selection: $selection) {
    ForEach(places) { place in
        Annotation(place.name, coordinate: place.coordinate, anchor: .bottom) {
            GlassMapPin(.symbol(place.symbol), title: place.name, tint: .accent, isSelected: selection == place.id)
        }
        .tag(place.id)
        .annotationTitles(.hidden)
    }
    ForEach(clusters) { cluster in                      // computed by the host or the engine
        Annotation("", coordinate: cluster.coordinate) {
            GlassMapPin(clusterCount: cluster.count, cap: 999)
        }
    }
}

Accessibility

  • One element per pin. Its label is the title, or the marker text when there is no title; clusters read "132 places" (after the title if there is one).
  • A selected pin has the .isSelected trait; selection is also visible by size, outline and the title, not by colour.
  • The marker grows with Dynamic Type (@ScaledMetric).

Limits

  • Clustering is left to the map engine: the pin does not know coordinates, does not merge and does not split. It only formats the count it is given.
  • A symbol-only pin without title has an empty accessibility label.
  • The marker is a capsule without a pointer tail; anchor the annotation on its centre or its bottom edge as the design requires.

Example

Complete example (compiled with the package)
import SwiftUI
import SPGlassKit

public struct GlassMapPinExample: GlassExample {
    public static let componentID = "glass-map-pin"

    private struct Place: Identifiable {
        let id: String
        let title: String
        let content: GlassMapPinContent
        let tint: GlassColorToken
        /// Position in the unit square of the placeholder map.
        let position: UnitPoint
    }

    /// Fictitious places.
    private let places = [
        Place(id: "cafe", title: "Café Exemple", content: .symbol("cup.and.saucer.fill"), tint: .primary, position: UnitPoint(x: 0.25, y: 0.3)),
        Place(id: "museum", title: "Musée fictif des très longs noms de lieux", content: .symbol("building.columns.fill"), tint: .accent, position: UnitPoint(x: 0.7, y: 0.25)),
        Place(id: "price", title: "Listing A-12", content: .text("$1.2M"), tint: .success, position: UnitPoint(x: 0.5, y: 0.55)),
        Place(id: "warning", title: "Road works", content: .symbol("exclamationmark.triangle.fill"), tint: .warning, position: UnitPoint(x: 0.2, y: 0.75)),
    ]
    @State private var selection: String? = "cafe"

    public init() {}

    public var body: some View {
        GeometryReader { proxy in
            SampleMapBackdrop()
                .overlay {
                    ForEach(places) { place in
                        Button {
                            selection = selection == place.id ? nil : place.id
                        } label: {
                            GlassMapPin(place.content, title: place.title, tint: place.tint, isSelected: selection == place.id)
                        }
                        .buttonStyle(.plain)
                        .position(x: proxy.size.width * place.position.x, y: proxy.size.height * place.position.y)
                    }
                    // Cluster markers: the count comes from the map engine, the pin only formats it.
                    GlassMapPin(clusterCount: 12)
                        .position(x: proxy.size.width * 0.8, y: proxy.size.height * 0.6)
                    GlassMapPin(clusterCount: 1_340, title: "Downtown")
                        .position(x: proxy.size.width * 0.75, y: proxy.size.height * 0.8)
                }
        }
    }
}

#Preview("GlassMapPin") { GlassMapPinExample().glassTheme(.solar) }

Registry entry

Identifierglass-map-pin
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassMapPinContent, GlassMapPinFormatting, GlassMapPinLayout, GlassMapPinShape, GlassMapPin
LicenceMIT
Manifestmanifest.json

Files