mapbox-android-patterns

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.

By mapbox · 1,157 installs

npx skills add mapbox/mapbox-agent-skills --skill mapbox-android-patterns

Source repository · Upstream listing

Mapbox Android Integration Patterns Official patterns for integrating Mapbox Maps SDK v11 on Android with Kotlin, Jetpack Compose, and View system. Use this skill when: Installing and configuring Mapbox Maps SDK for Android Adding markers and annotations to maps Showing user location and tracking with camera Adding custom data (GeoJSON) to maps Working with map styles, camera, or user interaction Handling feature interactions and taps Official Resources: [Android Maps Guides](https://docs.mapbox.com/android/maps/guides/) [API Reference](https://docs.mapbox.com/android/maps/api reference/) [Example Apps](https://github.com/mapbox/mapbox maps android/tree/main/Examples) Installation & Setup Requirements Android SDK 21+ Kotlin or Java Android Studio Free Mapbox account Step 1: Configure Access Token Create app/res/values/mapbox access token.xml : Get your token: Sign in at [mapbox.com](https://account.mapbox.com/access tokens/) Step 1b: Internet permission (required) Maps need network access. Include this in AndroidManifest.xml — agents often omit it and only list location permissions later: Step 2: Add Maven Repository In settings.gradle.kts : Step 3: Add Dependency In module build.gradle.kts : For Jetpack Compose: Map Initialization Jetpack Compose Pattern Basic map: With ornaments: View System Pattern Layout XML (activity map.xml): Activity: Add Markers (Point Annotations) Point annotations are the most common way to mark locations on the map. Jetpack Compose: View System: Multiple markers: Show User Location (Display) Step 1: Add permissions to AndroidManifest.xml: Step 2: Request permissions and show location: Performance Best Practices Reuse Annotation Managers Batch Annotation Updates Lifecycle Management Use Standard Style Troubleshooting Map Not Displaying Check: 1. Token in mapbox access token.xml 2. Token is valid (test at mapbox.com) 3. Maven repository configured 4. Dependency added correctly 5. Internet permission in manifest Style Not Loading Performance Issues Use Style.STANDARD (recommended and optimized) Limit visible annotations to viewport Reuse annotation managers Avoid frequent style reloads Call lifecycle methods (onStart, onStop, onDestroy) Batch annotation updates Reference Files Load these references when you need detailed patterns for specific topics: references/compose.md Jetpack Compose: dependencies, token setup, MapboxMap, annotations with click, GeoJSON, MapEffect references/annotations.md Circle, Polyline, and Polygon annotation patterns references/location tracking.md Camera follow user location + get current location once references/custom data.md GeoJSON sources and layers: lines, polygons, points, update/remove references/camera styles.md Camera control (set, animate, fit) + map styles (built in and custom) references/interactions.md Featureset interactions, custom layer taps, long press, gestures Additional Resources [Android Maps Guides](https://docs.mapbox.com/android/maps/guides/) [API Reference](https://docs.mapbox.com/android/maps/api/11.18.1/) [Interactions Guide](https://docs.mapbox.com/android/maps/guides/user interaction/interactions/) [Jetpack Compose Guide](https://docs.mapbox.com/android/maps/guides/using jetpack compose/) [Example Apps](https://github.com/mapbox/mapbox maps android/tree/main/Examples) [Migration Guide (v10 v11)](https://docs.mapbox.com/android/maps/guides/migrate to v11/)