MapLibre SwiftUI DSL provides a declarative API for integrating MapLibre Native into SwiftUI applications. It offers MapKit-like ease of use while maintaining the power and flexibility of MapLibre Native, enabling iOS developers to create beautiful, interactive maps with SwiftUI syntax.
Quick start
.package(url: "https://github.com/maplibre/swiftui-dsl", branch: "main"),
// target dependency
.product(name: "MapLibreSwiftUI", package: "swiftui-dsl"),import CoreLocation
import MapLibreSwiftUI
import SwiftUI
struct MyMapView: View {
@State var camera: MapViewCamera = .center(
CLLocationCoordinate2D(latitude: 47.3769, longitude: 8.5417),
zoom: 10
)
var body: some View {
MapView(
styleURL: URL(string: "https://tiles.openfreemap.org/styles/liberty")!,
camera: $camera
)
}
}›Setup noteschecked with v0.25.0
In Xcode, add the package from File > Add Package Dependencies with https://github.com/maplibre/swiftui-dsl. It works on iOS 15 or later, and the package needs Swift tools 6.2. It is pre-1.0, so the API can still change between releases.
Other platforms are on SDKs.
