Skip to main content
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.
Ir a la instalación Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/mapbox/mapbox-agent-skills --skill mapbox-android-patternsEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... Más de este repositorio mapbox-data-visualization-patterns Patterns for visualizing data on maps including choropleth maps, heat maps, 3D visualizations, data-driven styling, and animated data. Covers layer types, color scales, and performance optimization.
mapbox-geospatial-operations Expert guidance on choosing the right geospatial tool based on problem type, accuracy requirements, and performance needs
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.
Explorador de archivos
9 archivos Ocupaciones relacionadas SOC
Basado en la clasificación ocupacional SOC
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:
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 version="1.0" encoding="utf-8" ?>
<resources xmlns:tools ="http://schemas.android.com/tools" >
<string name = =
= > YOUR_MAPBOX_ACCESS_TOKEN
"mapbox_access_token"
translatable
"false"
tools:ignore
"UnusedResources"
</string >
</resources >
Step 1b: Internet permission (required) Maps need network access. Include this in AndroidManifest.xml — agents often omit it and only list location permissions later:
<uses-permission android:name ="android.permission.INTERNET" />
Step 2: Add Maven Repository dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://api.mapbox.com/downloads/v2/releases/maven" )
}
}
}
Step 3: Add Dependency In module build.gradle.kts:
android {
defaultConfig {
minSdk = 21
}
}
dependencies {
implementation("com.mapbox.maps:android:11.18.1" )
}
dependencies {
implementation("com.mapbox.maps:android:11.18.1" )
implementation("com.mapbox.extension:maps-compose:11.18.1" )
}
Map Initialization
Jetpack Compose Pattern 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()
) {
MapEffect(Unit ) { mapView ->
mapView.mapboxMap.setCamera(
CameraOptions.Builder()
.center(Point.fromLngLat(-122.4194 , 37.7749 ))
.zoom(12.0 )
.build()
)
}
}
}
MapboxMap(
modifier = Modifier.fillMaxSize(),
scaleBar = {
ScaleBar(
enabled = true ,
position = Alignment.BottomStart
)
},
compass = {
Compass(enabled = true )
}
) {
}
View System Pattern Layout XML (activity_map.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 >
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.
MapboxMap(modifier = Modifier.fillMaxSize()) {
MapEffect(Unit ) { mapView ->
mapView.mapboxMap.loadStyle(Style.STANDARD)
val annotationManager = mapView.annotations.createPointAnnotationManager()
val pointAnnotation = PointAnnotationOptions()
.withPoint(Point.fromLngLat(-122.4194 , 37.7749 ))
.withIconImage("custom-marker" )
annotationManager.create(pointAnnotation)
}
}
val pointAnnotationManager = mapView.annotations.createPointAnnotationManager()
val pointAnnotation = PointAnnotationOptions()
.withPoint(Point.fromLngLat(-122.4194 , 37.7749 ))
.withIconImage("custom-marker" )
pointAnnotationManager.create(pointAnnotation)
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:
<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:
mapView.location.updateSettings {
enabled = true
puckBearingEnabled = true
}
Performance Best Practices
Reuse Annotation Managers
val pointAnnotationManager = mapView.annotations.createPointAnnotationManager()
fun updateMarkers () {
pointAnnotationManager.deleteAll()
pointAnnotationManager.create(markers)
}
Batch Annotation Updates
pointAnnotationManager.create(allAnnotations)
Lifecycle Management
override fun onStart () {
super .onStart()
mapView.onStart()
}
override fun onStop () {
super .onStop()
mapView.onStop()
}
override fun onDestroy () {
super .onDestroy()
mapView.onDestroy()
}
Use Standard Style
Style.STANDARD
Style.STANDARD_SATELLITE
Troubleshooting
Map Not Displaying
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 mapView.mapboxMap.subscribeStyleLoaded { _ ->
Log.d("Map" , "Style loaded successfully" )
}
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