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:
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
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:
- Token in
mapbox_access_token.xml - Token is valid (test at mapbox.com)
- Maven repository configured
- Dependency added correctly
- 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, MapEffectreferences/annotations.md-- Circle, Polyline, and Polygon annotation patternsreferences/location-tracking.md-- Camera follow user location + get current location oncereferences/custom-data.md-- GeoJSON sources and layers: lines, polygons, points, update/removereferences/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


