SPB Git

Repository Public MIT

doc-glass-map-pin.md 3.5 KB 75 lines markdown

1# GlassMapPin23| | |4|---|---|5| Identifier | `glass-map-pin` |6| Module | `SPGlassMaps` |7| Kind | `content-component` — an opaque tinted pin with a tail; no glass |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Maps/GlassMapPinExample.swift` |1011## Minimal usage1213```swift14GlassMapPin(.symbol("fork.knife"), title: "Chez Sample")15```1617## Variants1819| Variant | Use |20|---|---|21| `.symbol(name)` | An SF Symbol in the marker. Always give a `title`: it is the accessibility label. |22| `.text(string)` | A short text (price, letter, rank), cut after 4 characters. |23| `init(clusterCount:cap:)` | A cluster marker: a disc with a halo and no tail, showing the localised count, or the cap followed by "+" ("99+"). |24| `isSelected: true` | Larger pin, thicker outline and the title on a chip under the tip. |25| `tint:` | Any colour role of the theme (`.primary`, `.accent`, `.success`, `.warning`, …). Text and symbol take the legible colour for that fill. |2627## Parameters2829| Parameter | Type | Default | Meaning |30|---|---|---|---|31| `content` | `GlassMapPinContent` | — | What the marker shows. |32| `title` | `String?` | `nil` | Name of the place: accessibility label, and visible label when selected. |33| `tint` | `GlassColorToken` | `.primary` (`.secondary` for clusters) | Colour role of the marker. |34| `isSelected` | `Bool` | `false` | Selected appearance and trait. |35| `clusterCount` | `Int` | — | Number of places the cluster stands for; negative values count as 0. |36| `cap` | `Int` | `99` | Largest count shown as a number. |3738**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.3940## States4142Normal 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).4344## Advanced example4546```swift47// MapKit; any other engine hosts the same view in its own annotation type.48Map(position: $engine.position, selection: $selection) {49    ForEach(places) { place in50        Annotation(place.name, coordinate: place.coordinate, anchor: .bottom) {51            GlassMapPin(.symbol(place.symbol), title: place.name, tint: .accent, isSelected: selection == place.id)52        }53        .tag(place.id)54        .annotationTitles(.hidden)55    }56    ForEach(clusters) { cluster in                      // computed by the host or the engine57        Annotation("", coordinate: cluster.coordinate) {58            GlassMapPin(clusterCount: cluster.count, cap: 999)59        }60    }61}62```6364## Accessibility6566- 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).67- A selected pin has the `.isSelected` trait; selection is also visible by size, outline and the title, not by colour.68- The marker grows with Dynamic Type (`@ScaledMetric`).6970## Limits7172- 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.73- A symbol-only pin without `title` has an empty accessibility label.74- The marker is a capsule without a pointer tail; anchor the annotation on its centre or its bottom edge as the design requires.75
Files main
Menu

Theme