All skills
mapbox avatar

/mapbox-ios-patterns

@f5ae7de official
by mapboxmapbox/mapbox-agent-skills80 stars
17

Official integration patterns for Mapbox Maps SDK on iOS. Covers installation, adding markers, user location, custom data, styles, camera control, and featureset interactions. Based on official Mapbox documentation.

Use this Skill: https://skilld.dev/gh/mapbox/mapbox-agent-skills/mapbox-ios-patterns

This session only. Nothing lands on disk.

referencescamera-styles.md

≈501 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Camera Control + Map Styles


Camera Control

Set Camera Position

// SwiftUI - Update viewport state
viewport = .camera(
    center: CLLocationCoordinate2D(latitude: 40.7128, longitude: -74.0060),
    zoom: 14,
    bearing: 90,
    pitch: 60
)

// UIKit - Immediate
mapView.mapboxMap.setCamera(to: CameraOptions(
    center: CLLocationCoordinate2D(latitude: 40.7128, longitude: -74.0060),
    zoom: 14,
    bearing: 90,
    pitch: 60
))

Animated Camera Transitions

// Fly animation (dramatic arc)
mapView.camera.fly(to: CameraOptions(
    center: destination,
    zoom: 15
), duration: 2.0)

// Ease animation (smooth)
mapView.camera.ease(to: CameraOptions(
    center: destination,
    zoom: 15
), duration: 1.0)

Fit Camera to Coordinates

let coordinates = [coord1, coord2, coord3]
let camera = mapView.mapboxMap.camera(for: coordinates,
                                       padding: UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50),
                                       bearing: 0,
                                       pitch: 0)
mapView.camera.ease(to: camera, duration: 1.0)

Map Styles

Built-in Styles

// SwiftUI
Map(viewport: $viewport)
    .mapStyle(.standard)        // Mapbox Standard (recommended)
    .mapStyle(.streets)          // Mapbox Streets
    .mapStyle(.outdoors)         // Mapbox Outdoors
    .mapStyle(.light)            // Mapbox Light
    .mapStyle(.dark)             // Mapbox Dark
    .mapStyle(.standardSatellite) // Satellite imagery

// UIKit
mapView.mapboxMap.loadStyle(.standard)
mapView.mapboxMap.loadStyle(.streets)
mapView.mapboxMap.loadStyle(.dark)

Custom Style URL

// SwiftUI
Map(viewport: $viewport)
    .mapStyle(MapStyle(uri: StyleURI(url: customStyleURL)!))

// UIKit
mapView.mapboxMap.loadStyle(StyleURI(url: customStyleURL)!)

Style from Mapbox Studio:

let styleURL = URL(string: "mapbox://styles/username/style-id")!

Source: SKILL.md on GitHub

1 warning17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill provides official integration patterns for the Mapbox Maps SDK on iOS, including installation, markers, location tracking, and custom data. It follows standard iOS development practices and utilizes official Mapbox resources. No security issues or malicious behaviors were detected.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    2/2 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f5ae7de. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 10 hours ago.

Activeupdated 2 months ago
  • mapbox
  • ios
  • swift
  • swiftui
  • uikit
  • maps
  • annotations
  • geojson
  • location-tracking
  • camera-control

README badge

README badge for mapbox/mapbox-agent-skills/mapbox-ios-patterns

Installs and configures Mapbox Maps SDK v11 on iOS with Swift and SwiftUI, covering markers, user location, custom data layers, camera control, and feature interactions. Targets both SwiftUI and UIKit workflows and includes performance guidance for annotation management and style optimization.

Generated from the current SKILL.md.

Does this skill work with both SwiftUI and UIKit?
Yes. The skill covers both frameworks. Some APIs like `Marker` are SwiftUI-only, while `PointAnnotation` and `ViewAnnotation` work in both SwiftUI and UIKit.
What iOS version is required?
iOS 14 or later, with Xcode 15+ and Swift 5.9+. Mapbox Maps SDK v11 is the target version.
How do I handle hundreds or thousands of markers?
Use a `GeoJSONSource` with a `SymbolLayer` instead of individual annotations. The Markers and PointAnnotation APIs scale to about 100 markers; for larger datasets, load GeoJSON directly into a style layer, which scales to thousands of features and supports clustering.
Do I need a paid Mapbox account?
No. A free Mapbox account is sufficient to get an access token and use the Maps SDK.
How do I show the user's location on the map?
Add the location permission string to Info.plist, request `requestWhenInUseAuthorization()` from CLLocationManager, then enable the location puck with `mapView.location.options.puckType = .puck2D()`.

Generated from the current SKILL.md. These answers refresh after source changes.