Migrate from the Mapbox Mobile SDK
MapLibre Native is a fork of the last open-source Mapbox Maps SDK, so a mobile app on the older Mapbox SDK maps over almost one to one. You swap the dependency, replace the Mapbox/MGL/com.mapbox.mapboxsdk names with their MapLibre equivalents, and point the map at the Maptoolkit community style URL - no access token required.
iOS
1. Swap the dependency in the Podfile
# Before
pod 'Mapbox-iOS-SDK', '~> 6.4'
# After
pod 'MapLibre'Run pod install and open the workspace again.
2. Update the code
The class prefix changes from MGL (Mapbox) to MLN (MapLibre), and you drop the access token.
// Before (Mapbox)
import Mapbox
MGLAccountManager.accessToken = "pk.your-mapbox-token"
let mapView = MGLMapView(frame: view.bounds,
styleURL: URL(string: "mapbox://styles/mapbox/streets-v11"))
// After (MapLibre + Maptoolkit)
import MapLibre
let mapView = MLNMapView(frame: view.bounds,
styleURL: URL(string: "https://styles.maptoolkit.org/summer.json"))Most MGL… types have a direct MLN… counterpart (MGLMapView → MLNMapView, MGLPointAnnotation → MLNPointAnnotation), so a find-and-replace of the MGL prefix with MLN covers most of the work. See MapLibre Native iOS.
Android
1. Swap the dependency in build.gradle
// Before
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1'
// After
implementation 'org.maplibre.gl:android-sdk:13.0.0'2. Update the code
In practice you only need to replace the package prefix com.mapbox.mapboxsdk with org.maplibre.gl across your imports and code (a project-wide find-and-replace), and drop the access token.
// Before (Mapbox)
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.maps.Style
Mapbox.getInstance(this, "pk.your-mapbox-token")
map.setStyle(Style.Builder().fromUri("mapbox://styles/mapbox/streets-v11"))
// After (MapLibre + Maptoolkit)
import org.maplibre.android.MapLibre
import org.maplibre.android.maps.Style
MapLibre.getInstance(this)
map.setStyle(Style.Builder().fromUri("https://styles.maptoolkit.org/summer.json"))The initializer changes from Mapbox.getInstance(context, token) to MapLibre.getInstance(context) (no token). See MapLibre Native Android.
Things to check
- No access token. Remove the Mapbox token from code and from
Info.plist/ resources. - Style URL. Replace any
mapbox://style URL with the Maptoolkit community style URL. - SDK version. This applies to the open-source Mapbox SDKs (iOS v6.x, Android v9.x and earlier). The newer proprietary Mapbox SDKs (iOS v10+, Android v10+) use a different API and need more than a prefix swap.
Attribution
Every map must show the Maptoolkit logo and the © Maptoolkit © OSM copyright line, both as tappable links. See Quick Start - Add attribution.