All skills
mapbox avatar

/mapbox-android-patterns

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

Official integration patterns for Mapbox Maps SDK on Android. 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-android-patterns

This session only. Nothing lands on disk.

referenceslocation-tracking.md

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

Camera Follow User + Get Current Location

Camera Follow User Location

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

class MapActivity : AppCompatActivity() {
    private lateinit var mapView: MapView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_map)

        mapView = findViewById(R.id.mapView)
        mapView.mapboxMap.loadStyle(Style.STANDARD)

        setupLocationTracking()
    }

    private fun setupLocationTracking() {
        // Request permissions first (use ActivityResultContracts)

        // Show user location
        mapView.location.updateSettings {
            enabled = true
            puckBearingEnabled = true
        }

        // Follow user location with camera
        mapView.location.addOnIndicatorPositionChangedListener { point ->
            mapView.camera.easeTo(
                CameraOptions.Builder()
                    .center(point)
                    .zoom(15.0)
                    .pitch(45.0)
                    .build(),
                MapAnimationOptions.Builder()
                    .duration(1000)
                    .build()
            )
        }

        // Optional: Follow bearing (direction) as well
        mapView.location.addOnIndicatorBearingChangedListener { bearing ->
            mapView.camera.easeTo(
                CameraOptions.Builder()
                    .bearing(bearing)
                    .build(),
                MapAnimationOptions.Builder()
                    .duration(1000)
                    .build()
            )
        }
    }

    override fun onStart() {
        super.onStart()
        mapView.onStart()
    }

    override fun onStop() {
        super.onStop()
        mapView.onStop()
    }

    override fun onDestroy() {
        super.onDestroy()
        mapView.onDestroy()
    }
}

Get Current Location Once

mapView.location.getLastLocation { location ->
    location?.let {
        val point = Point.fromLngLat(it.longitude, it.latitude)
        mapView.camera.easeTo(
            CameraOptions.Builder()
                .center(point)
                .zoom(14.0)
                .build()
        )
    }
}

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides official integration patterns for the Mapbox Maps SDK for Android. It uses official Mapbox repositories and follows standard Android development best practices for secret management and permissions.

  • Socket16d

    No alerts

  • Snyk16d

    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 3 hours ago.

Activeupdated 2 months ago
  • mapbox
  • android
  • kotlin
  • jetpack-compose
  • maps
  • annotations
  • geolocation
  • gis

README badge

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

Official patterns for integrating Mapbox Maps SDK v11 on Android with Kotlin, Jetpack Compose, and the View system. Covers initialization, markers, user location display, custom data, styles, camera control, and feature interactions.

Generated from the current SKILL.md.

Does this skill cover both Jetpack Compose and the View system?
Yes. The skill includes patterns for both Jetpack Compose and the traditional View system, with separate code examples for each approach.
What is the minimum Android SDK version required?
Android SDK 21 or higher is required.
Do I need to configure an access token before using Mapbox Maps?
Yes. You must create a Mapbox account, get an access token, and store it in `app/res/values/mapbox_access_token.xml` for the SDK to work.
Does this skill cover GeoJSON, custom layers, and user interactions?
The skill provides an overview and references to detailed patterns. Full coverage of GeoJSON sources, custom layers, and feature interactions is in the bundled reference files (custom-data.md, camera-styles.md, and interactions.md).
What version of Mapbox Maps SDK does this skill target?
Mapbox Maps SDK v11 for Android, with the most recent tested version being 11.18.1.

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