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.

referenceslocation-tracking.md

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

Location Tracking: Camera Follow User + Get Current Location

Advanced location patterns beyond basic user location display (covered in SKILL.md).


Camera Follow User Location

To make the camera follow the user's location as they move:

import Combine

class MapViewController: UIViewController {
    private var mapView: MapView!
    private var cancelables = Set<AnyCancellable>()

    override func viewDidLoad() {
        super.viewDidLoad()
        setupMap()
        setupLocationTracking()
    }

    func setupLocationTracking() {
        // Request permissions
        let locationManager = CLLocationManager()
        locationManager.requestWhenInUseAuthorization()

        // Show user location
        mapView.location.options.puckType = .puck2D()
        mapView.location.options.puckBearingEnabled = true

        // Follow user location with camera
        mapView.location.onLocationChange.observe { [weak self] locations in
            guard let self = self, let location = locations.last else { return }

            self.mapView.camera.ease(to: CameraOptions(
                center: location.coordinate,
                zoom: 15,
                bearing: location.course >= 0 ? location.course : nil,
                pitch: 45
            ), duration: 1.0)
        }.store(in: &cancelables)
    }
}

Get Current Location Once

if let location = mapView.location.latestLocation {
    let coordinate = location.coordinate
    print("User at: \(coordinate.latitude), \(coordinate.longitude)")

    // Move camera to user location
    mapView.camera.ease(to: CameraOptions(
        center: coordinate,
        zoom: 14
    ), duration: 1.0)
}

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 11 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.