Migrate to v11
This document is a guide for migrating from v10 of the Mapbox Maps SDK for Android to the v11. It includes information about new features, deprecated APIs, and breaking changes.
Version Compatibility
Version | Minimum Android Version | Kotlin Version | Target/Compile SDK Version | NDK Version | OpenGL |
---|---|---|---|---|---|
11.0.0 | 5.0 (API level 21) | 1.6.0 or later | 33 | 23.2.8568313 | OpenGL ES 3.0 |
Mapbox Maps SDK v11 was complied with the following dependencies:
- Kotlin 1.7.20 and binary compatibility with Kotlin compiler 1.6 and above.
- Compile SDK Version 33, which is also the minimum target SDK level for new apps published to Google Play Store.
- Android X libraries which requires
minCompileSdk (33)
, if you are not able to update to compileSDK 33, force an older version of Android X libraries in app’s build.gradle:
implementation("androidx.appcompat:appcompat") { version { strictly("1.4.2") } }
implementation("androidx.core:core-ktx") { version { strictly("1.8.0") } }
Explore new features
The Mapbox Standard Style and Mapbox Standard Satellite Styles
With the Mapbox Maps SDK v11 we are introducing Mapbox Standardand Mapbox Standard Satellite, our latest Mapbox style. The new Mapbox Standard core style enables a highly performant and elegant 3D mapping experience with powerful dynamic lighting capabilities, landmark 3D buildings, and an expertly crafted symbolic aesthetic. With Mapbox Standard and Mapbox Standard Satellite, we are also introducing a new paradigm for how to interact with map styles.
To set Mapbox Standard as the style for your map in v11 you can use the Style.STANDARD
constant like below:
mapboxMap.loadStyle(Style.STANDARD)
The Mapbox Standard and Mapbox Standard Satellite styles features 4 light presets: day
, dusk
, dawn
, and night
. The style light preset can be changed from the default, “Day”, to another preset with a single line of code. Here you identify which imported style (basemap
) you want to change the lightPresent
configuration on, as well as the value (dusk
) you want to change it to.
mapboxMap.loadStyle(Style.STANDARD) { style ->
style.setStyleImportConfigProperty(styleImportId, "lightPreset", Value.valueOf("dusk"))
}
Light preset "day " (default) | Light preset "dusk " |
---|---|
Changing the light preset will alter the colors and shadows on your map to reflect the time of day. For more information, see the Lighting API section. Similarly, you can set other configuration properties on the Standard style such as showing POIs, place labels, or specific fonts:
mapboxMap.loadStyle(Style.STANDARD) { style ->
style.setStyleImportConfigProperty(styleImportId, "showPointOfInterestLabels", Value.valueOf(false))
}
The Standard style offers 8 configuration properties for developers to change when they import it into their own style:
Property | Type | Description |
---|---|---|
showPlaceLabels | Bool | Shows and hides place label layers. |
showRoadLabels | Bool | Shows and hides all road labels, including road shields. |
showPointOfInterestLabels | Bool | Shows or hides all POI icons and text. |
showTransitLabels | Bool | Shows or hides all transit icons and text. |
show3dObjects | Bool | Shows or hides all 3d layers (3D buildings, landmarks, trees, etc.) including shadows, ambient occlusion, and flood lights. Important: configuration available starting from v11.5.1 SDK |
theme | String | Switches between 3 themes: default , faded and monochrome . Important: configuration available starting from v11.5.1 SDK |
lightPreset | String | Switches between 4 time-of-day states: dusk , dawn , day , and night . |
font | String | Defines font family for the style from predefined options. |
The Standard Satellite Style (mapbox://styles/mapbox/standard-satellite
) combines updated satellite imagery and vector layers to offer users improved clarity and detail. Like Standard style, the Satellite Style receives all updates automatically and also supports light presets. Additionally, it introduces two new configurations showRoadsAndTransit
and showPedestrianRoads
. Users can now choose to hide roads, simplifying the map style for a better focus on specific areas or features.
The Standard Satellite style offers 8 configuration properties for developers to change when they import it into their own style:
Property | Type | Description |
---|---|---|
showRoadsAndTransit | Bool | Shows and hides all roads and transit networks. |
showPedestrianRoads | Bool | Shows and hides all pedestrian roads, paths, trails. |
showPlaceLabels | Bool | Shows and hides place label layers. |
showRoadLabels | Bool | Shows and hides all road labels, including road shields. |
showPointOfInterestLabels | Bool | Shows or hides all POI icons and text. |
showTransitLabels | Bool | Shows or hides all transit icons and text. |
lightPreset | String | Switches between 4 time-of-day states: dusk , dawn , day , and night . |
font | String | Defines font family for the style from predefined options. |
Important: Standard satellite style doesn't support theme and show3dObjects configuration. |
Mapbox Standard and Mapbox Standard Satellite are making adding your own data layers easier for you through the concept of slot
s. Slot
s are predefined locations in the style where your layer will be added to (such as on top of existing land layers, but below all labels). To do this, we've added a new slot
property to each Layer
. This property allows you to identify which slot
in the Mapbox Standard your new layer should be placed in. To add custom layers in the appropriate location in the Standard or Standard Satellite style layer stack, we added 3 carefully designed slots that you can leverage to place your layer. These slots will not change, so you can be sure that your own map won't break even as the basemap evolves automatically.
Slot | Description |
---|---|
bottom | Above polygons (land, landuse, water, etc.) |
middle | Above lines (roads, etc.) and behind 3D buildings |
top | Above POI labels and behind Place and Transit labels. Designed to be used with the symbol layers. |
not specified | Above all existing layers in the style |
Set the preferred slot
on the Layer
object before adding it to your map and your layer will be appropriately placed in the Standard style's layer stack. If no slot is specified for a custom layer they are placed at the top of the layer list, providing a location that has highest collision priority compared to all other layers.
+lineLayer(layerId = "line-layer", sourceId = "line-layer") {
lineColor(rgb(255.0, 165.0, 0.0))
slot("middle")
}
For the new Standard or Standard Satellite styles, you can only add layers to these three slots (bottom
, middle
, top
) within the Standard and Standard Satellite style basemaps.
And when a layer type such as background
, fill
, line
, circle
, hillshade
or heatmap
is added to the top
slot in the Standard or Standard Satellite Style, it will be positioned below all labels. This behavior is due to the design of the top
slot in the Standard or Standard Satellite Style, which is primarily intended for use with symbol
layers.
Like to the classic Mapbox styles, you can still use LayerPosition
when importing the Standard or Standard Satellite Style. This method is only applicable to custom layers you have added yourself. If you add two layers to the same slot with a specified layer position the latter will define the order of the layers in that slot.
Standard and Standard Satellite Style are aware of the map lighting configuration using the measure-light
expression, which returns you an aggregated value of your light settings. This returns a value which ranges from 0 (darkest) to 1 (brightest). In darker lights, you make the individual layers light up by using the new *-emissive-stength
expressions, which allow you to add emissive light to different layer types and for example keep texts legible in all light settings. If your custom layers seem too dark, try adjusting the emissive strength of these layers.
Customizing Standard
The underlying design paradigm to the Standard style is different from what you know from the classic core styles. Mapbox manages the basemap experience and surfaces key global styling configurations - in return, you get a cohesive visual experience and an evergreen map, always featuring the latest data, styling and rendering features compatible with your SDK. The configuration options make interactions with the basemap simpler than before. During the beta phase, we are piloting these configurations - we welcome feedback on the beta configurations. If you have feedback or questions about the Standard beta style reach out to: hey-map-design@mapbox.com.
You can customize the color of your Standard or Standard Satellite Style experience by adjusting the 3D light settings. Individual basemap layers and/or color values can’t be adjusted, but all the flexibility offered by the style specification can be applied to custom layers while keeping interaction with the basemap simple through slot
s.
Our existing, classic Mapbox styles (such as Mapbox Streets, Mapbox Light, and Mapbox Satellite Streets) and any custom styles you have built in Mapbox Studio will still work like they do in v10, so no changes are required.
Style Imports
To work with styles like Mapbox Standard or Standard Satellite, we've introduced new Style APIs that allow you to import other styles into the main style you display to your users. These styles will be imported by reference, so updates to them will be reflected in your main style without additional work needed on your side. For example, imagine you have style A and style B. The Style API will allow you to import A into B. Upon importing, you can set configurations that apply to A and adjust them at runtime. The configuration properties for the imported style A will depend on what the creator of style A chooses to be configurable. For the Standard style, 6 configuration properties are available for setting lighting, fonts, and label display options (see The Mapbox Standard Style section above).
To import a style, you should add an "imports" section to your Style JSON. In the above example, you would add this "imports" section to your Style JSON for B to import style A and set various configurations such as Montserrat
for the font
and dusk
for the lightPreset
.
...
"imports": [
{
"id": "A",
"url": "STYLE_URL_FOR_A",
"config": {
"font": "Montserrat",
"lightPreset": "dusk",
"theme": "faded",
"show3dObjects: true,
"showPointOfInterestLabels": true,
"showTransitLabels": false,
"showPlaceLabels": true,
"showRoadLabels": false
}
}
],
...
For a full example of importing a style, take a look at our Standard Style Example. This example imports the Standard style into another style Real Estate New York.
We've introduced new APIs on the Style
object so you can work with these features:
style.styleImports
, which returns all the styles you have imported into your main stylestyle.removeStyleImport()
, which removes the style import with the passed Idstyle.getStyleImportSchema()
, which returns the full schema describing the style import with the passed Idstyle.getStyleImportConfigProperties()
, which returns all the configuration properties of the style import with the passed Idstyle.getStyleImportConfigProperty()
, which returns the specified configuration property of the style import with the passed Idstyle.setStyleImportConfigProperties()
, which sets all the configuration properties of the style import with the passed Idstyle.setStyleImportConfigProperty()
, which sets the specified configuration property of the style import with the passed Id
Besides modifying the configuration properties of the imported styles, you can add your own layers to the imported style through the concept of slot
s. Slot
s are predefined locations in the imported style where your layer will be added to (such as on top of existing land layers, but below all labels). To do this, we've added a new slot
property to each Layer
. This property allows you to identify which slot
in the imported style your new layer should be placed in.
+lineLayer(layerId = "line-layer", sourceId = "line-layer") {
lineColor(rgb(255.0, 165.0, 0.0))
slot("middle")
}
For more information, see The Mapbox Standard Style section above.
Migration steps
1. Update dependencies
Update your app's dependencies to use the latest version of the Mapbox Maps SDK for Android.
dependencies {
implementation 'com.mapbox.maps:android:11.0.0'
}
2. Replace deprecated APIs
Check for deprecated APIs in your code and replace them with the recommended alternatives. Deprecated APIs may be removed in future releases.