MapLibre setup
How to drive MapLibre Native through MapConductor. It needs no API key and is the fastest provider to get running; the look of the map comes from wherever the style JSON is served.
Before you start
Add it with Swift Package Manager
Use File > Add Package Dependencies in Xcode and paste the package URL. The MapLibre Native SDK comes in automatically as a dependency.
https://github.com/MapConductor/ios-for-maplibre
dependencies: [
.package(url: "https://github.com/MapConductor/ios-sdk-core", from: "1.1.4"),
.package(url: "https://github.com/MapConductor/ios-for-maplibre", from: "1.0.0"),
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "MapConductorCore", package: "ios-sdk-core"),
.product(name: "MapConductorForMapLibre", package: "ios-for-maplibre"),
]
),
]Choose a style
MapLibre itself has no account and no key — but you do choose where tiles come from. With a commercial service such as MapTiler, that provider's key is embedded in the style JSON URL. MapConductor takes no part in tile-provider authentication.
// Built-in presets mapState.mapDesignType = MapLibreDesign.OsmBright mapState.mapDesignType = MapLibreDesign.OsmBrightJa mapState.mapDesignType = MapLibreDesign.MapTilerTonerEn mapState.mapDesignType = MapLibreDesign.DemoTiles
Add the location permission (if needed)
If you use location, declare the purpose in Info.plist and request permission from the app.
<key>NSLocationWhenInUseUsageDescription</key> <string>We need your location to display on the map</string>
import CoreLocation
final class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
private let manager = CLLocationManager()
override init() {
super.init()
manager.delegate = self
}
func requestPermission() {
manager.requestWhenInUseAuthorization()
}
}VERIFY
What you should see
Render the map with a style. Tiles loading, plus working zoom and pan, means you are done.
import SwiftUI
import MapConductorCore
import MapConductorForMapLibre
struct ContentView: View {
@StateObject var mapState = MapLibreViewState(
mapDesignType: MapLibreDesign.OsmBright,
cameraPosition: MapCameraPosition(
position: GeoPoint(latitude: 35.6812, longitude: 139.7671),
zoom: 12.0
)
)
var body: some View {
MapLibreMapView(state: mapState)
.ignoresSafeArea()
}
}Map designs
Each MapLibreDesign wraps a style JSON URL. To use your own style, construct the type directly.
Troubleshooting
The map stays blank
- Check the style JSON URL behind your chosen MapLibreDesign is reachable.
- If you use a tile provider, verify the key embedded in the URL is still valid.
- Check the deployment target is iOS 15.1 or later.
The build fails
- Clean the build folder (Cmd+Shift+K).
- Delete ~/Library/Developer/Xcode/DerivedData and rebuild.
- Refresh the Swift Package Manager dependencies, and avoid mixing in CocoaPods.
Next
With MapLibreMapView on screen, overlays go on through the same shared API as every other provider.