mapbox-android-patterns
This skill provides official patterns for integrating Mapbox Maps SDK v11 on Android, covering setup, map initialization, markers, user location display…
Identity proven by GitHub's verified organisation badge (mapbox)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- f71cd72pinned Oct 9, 2026
- Context cost
- about 2,500 tokenswhen the skill loads
- GitHub stars
- 80on mapbox/mapbox-agent-skills
- Scripts
- None found
What it does
“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.”
Generated summary from the skill's own text
This skill provides official patterns for integrating Mapbox Maps SDK v11 on Android, covering setup, map initialization, markers, user location display, custom data layers, styles, camera control, and interactions. It supports both Jetpack Compose and View system implementations with Kotlin code examples and best practices for performance and lifecycle management.
When to use it
- Building Android apps with interactive maps and location features
- Adding markers, annotations, or custom GeoJSON data to maps
- Displaying user location and camera tracking on maps
- Styling maps and controlling camera position programmatically
When not to
- Projects requiring Google Maps instead of Mapbox
- Web-based map applications or non-Android platforms
- Simple static map displays without interaction needs
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add mapbox/mapbox-agent-skills --skill mapbox-android-patternsInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install mapbox/mapbox-agent-skills mapbox-android-patterns@f71cd72b8d8937b06db440538bd65559eb792c49Installs the commit we checked (f71cd72).
Copy by hand
Download the folder at f71cd72 and put it in .claude/skills/mapbox-android-patterns for Claude Code and in .agents/skills/mapbox-android-patterns for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install mapbox@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "mapbox-android-patterns" by Mapbox. Source, pinned to commit f71cd72b8d8937b06db440538bd65559eb792c49: https://github.com/mapbox/mapbox-agent-skills/tree/f71cd72b8d8937b06db440538bd65559eb792c49/skills/mapbox-android-patterns 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/mapbox-android-patterns/ for Claude Code and .agents/skills/mapbox-android-patterns/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/mapbox/mapbox-android-patterns
SKILL.md at the pin
---
name: mapbox-android-patterns
description: 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.
---
# 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`:
```xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="mapbox_access_token" translatable="false"
tools:ignore="UnusedResources">YOUR_MAPBOX_ACCESS_TOKEN</string>
</resources>
```
**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:
```xml
<uses-permission android:name="android.permission.INTERNET" />
```
### Step 2: Add Maven Repository
In `settings.gradle.kts`:
```kotlin
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://api.mapbox.com/downloads/v2/releases/maven")
}
}
}
```
### Step 3: Add Dependency
In module `build.gradle.kts`:
```kotlin
android {
defaultConfig {
minSdk = 21
}
}
dependencies {
implementation("com.mapbox.maps:android:11.18.1")
}
```
**For Jetpack Compose:**
```kotlin
dependencies {
implementation("com.mapbox.maps:android:11.18.1")
implementation("com.mapbox.extension:maps-compose:11.18.1")
}
```
---
## Map Initialization
### Jetpack Compose Pattern
**Basic map:**
```kotlin
import androidx.compose.runtime.*
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import com.mapbox.maps.extension.compose.*
import com.mapbox.maps.Style
import com.mapbox.geojson.Point
@Composable
fun MapScreen() {
MapboxMap(
modifier = Modifier.fillMaxSize()
) {
// Initialize camera via MapEffect (Style.STANDARD loads by default)
MapEffect(Unit) { mapView ->
// Set initial camera position
mapView.mapboxMap.setCamera(
CameraOptions.Builder()
.center(Point.fromLngLat(-122.4194, 37.7749))
.zoom(12.0)
.build()
)
}
}
}
```
**With ornaments:**
```kotlin
MapboxMap(
modifier = Modifier.fillMaxSize(),
scaleBar = {
ScaleBar(
enabled = true,
position = Alignment.BottomStart
)
},
compass = {
Compass(enabled = true)
}
) {
// Style.STANDARD loads by default
}
```
### View System Pattern
**Layout XML (activity_map.xml):**
```xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
```
**Activity:**
```kotlin
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.maps.MapView
import com.mapbox.maps.Style
import com.mapbox.geojson.Point
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.setCamera(
CameraOptions.Builder()
.center(Point.fromLngLat(-122.4194, 37.7749))
.zoom(12.0)
.build()
)
mapView.mapboxMap.loadStyle(Style.STANDARD)
}
override fun onStart() {
super.onStart()
mapView.onStart()
}
override fun onStop() {
super.onStop()
mapView.onStop()
}
override fun onDestroy() {
super.onDestroy()
mapView.onDestroy()
}
}
```
---
## Add Markers (Point Annotations)
Point annotations are the most common way to mark locations on the map.
**Jetpack Compose:**
```kotlin
MapboxMap(modifier = Modifier.fillMaxSize()) {
MapEffect(Unit) { mapView ->
// Load style first
mapView.mapboxMap.loadStyle(Style.STANDARD)
// Create annotation manager and add markers
val annotationManager = mapView.annotations.createPointAnnotationManager()
val pointAnnotation = PointAnnotationOptions()
.withPoint(Point.fromLngLat(-122.4194, 37.7749))
.withIconImage("custom-marker")
annotationManager.create(pointAnnotation)
}
}
// Note: Compose doesn't have declarative PointAnnotation component
// Markers must be added imperatively via MapEffect
```
**View System:**
```kotlin
// Create annotation manager (once, reuse for updates)
val pointAnnotationManager = mapView.annotations.createPointAnnotationManager()
// Create marker
val pointAnnotation = PointAnnotationOptions()
.withPoint(Point.fromLngLat(-122.4194, 37.7749))
.withIconImage("custom-marker")
pointAnnotationManager.create(pointAnnotation)
```
**Multiple markers:**
```kotlin
val locations = listOf(
Point.fromLngLat(-122.4194, 37.7749),
Point.fromLngLat(-122.4094, 37.7849),
Point.fromLngLat(-122.4294, 37.7649)
)
val annotations = locations.map { point ->
PointAnnotationOptions()
.withPoint(point)
.withIconImage("marker")
}
pointAnnotationManager.create(annotations)
```
---
## Show User Location (Display)
**Step 1: Add permissions to AndroidManifest.xml:**
```xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
```
**Step 2: Request permissions and show location:**
```kotlin
// Request permissions first (use ActivityResultContracts)
// Show location puck
mapView.location.updateSettings {
enabled = true
puckBearingEnabled = true
}
```
---
## Performance Best Practices
### Reuse Annotation Managers
```kotlin
// Don't create new managers repeatedly
// val manager = mapView.annotations.createPointAnnotationManager() // each call
// Create once, reuse
val pointAnnotationManager = mapView.annotations.createPointAnnotationManager()
fun updateMarkers() {
pointAnnotationManager.deleteAll()
pointAnnotationManager.create(markers)
}
```
### Batch Annotation Updates
```kotlin
// Create all at once
pointAnnotationManager.create(allAnnotations)
// Don't create one by one in a loop
```
### Lifecycle Management
```kotlin
// Always call lifecycle methods
override fun onStart() {
super.onStart()
mapView.onStart()
}
override fun onStop() {
super.onStop()
mapView.onStop()
}
override fun onDestroy() {
super.onDestroy()
mapView.onDestroy()
}
```
### Use Standard Style
```kotlin
// Standard style is optimized and recommended
Style.STANDARD
// Use other styles only when needed for specific use cases
Style.STANDARD_SATELLITE // Satellite imagery
```
---
## 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
```kotlin
mapView.mapboxMap.subscribeStyleLoaded { _ ->
Log.d("Map", "Style loaded successfully")
// Add layers and sources here
}
```
### 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/)
From mapbox/mapbox-agent-skills at f71cd72, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.md.
View SKILL.md on GitHub at f71cd72Files
- SKILL.md10 KB · 884652c6550b
- AGENTS.md8.2 KB · 48987f7eee9a
- evals/
- evals.json4.0 KB · 26c995e691ba
- references/
- annotations.md1.1 KB · 401ac792a475
- camera-styles.md2.4 KB · 8de5383f02c8
- compose.md3.6 KB · 3bd6e0001720
- custom-data.md2.4 KB · a23b0b62cc18
- interactions.md3.9 KB · 02f146865385
- location-tracking.md2.3 KB · 284dc447d005
9 files, 38 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at f71cd72More from Mapbox
mapbox-cartography
This skill provides cartographic expertise for designing effective maps with Mapbox, covering visual hierarchy, color theory, typography, and zoom strategies.
Claude Code, Codex, Cursor +4 · about 1.7K tokens · pinned 6 days ago
mapbox-data-visualization-patterns
This skill teaches the agent to implement data visualization patterns on Mapbox maps, including choropleth maps, heat maps, 3D extrusions, and animated data…
Claude Code, Codex, Cursor +4 · about 2.1K tokens · pinned 6 days ago
mapbox-flutter-patterns
This skill teaches agents the standard patterns for integrating the Mapbox Maps Flutter SDK into iOS and Android apps written in Dart.
Claude Code, Codex, Cursor +4 · about 2.3K tokens · pinned 6 days ago
mapbox-geospatial-operations
This skill guides agents on selecting appropriate geospatial tools from the Mapbox MCP Server based on problem requirements.
Claude Code, Codex, Cursor +4 · about 4.8K tokens · pinned 6 days ago
mapbox-google-maps-migration
This skill guides developers migrating from Google Maps Platform to Mapbox GL JS by comparing APIs, translating patterns, and highlighting architectural…
Claude Code, Codex, Cursor +4 · about 2.9K tokens · pinned 6 days ago
mapbox-ios-patterns
Integrates Mapbox Maps SDK v11 on iOS using Swift and SwiftUI, enabling map display, marker placement, user location tracking, and custom data rendering.
Claude Code, Codex, Cursor +4 · about 2.6K tokens · pinned 6 days ago
Related in Mobile
expo-app-intents
This skill adds Apple App Intents to Expo apps, enabling Siri voice commands and Shortcuts automation through Swift declarations that dispatch to JavaScript…
by ExpoOfficial publisher
Claude Code, Codex, Cursor +4 · about 3.6K tokens · pinned 6 days ago
eas-app-stores
This skill configures and executes iOS and Android app builds and store submissions using EAS, Expo's app distribution service.
by ExpoOfficial publisher
Claude Code, Codex, Cursor +3 · about 1.7K tokens · pinned 6 days ago
eas-simulator
Runs a user's app on a remote iOS or Android simulator hosted on EAS cloud infrastructure, accessible from machines without local simulator support like Linux…
by ExpoOfficial publisher
Claude Code, Codex, Cursor +3 · about 6.3K tokens · pinned 6 days ago
eas-update
Configures and publishes over-the-air JavaScript and asset updates using EAS Update and the EAS CLI.
by ExpoOfficial publisher
Claude Code, Codex, Cursor +3 · about 2.3K tokens · pinned 6 days ago
expo-animation
This skill guides building animations in React Native and Expo apps using Reanimated, Gesture Handler, and Expo Router.
by ExpoOfficial publisher
Claude Code, Codex, Cursor +3 · about 4.6K tokens · pinned 6 days ago
expo-app-clip
This skill adds an iOS App Clip target to an Expo project, creating a lightweight app experience invoked from URLs on your domain.
by ExpoOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.3K tokens · pinned 6 days ago