MapSDK Getting Started
Embed a customizable, interactive Wemap map in your app.
Overview
WemapMapSDK renders MapLibre-based maps configured for your Wemap map. You drive it with a
MapSession, which loads the map's data once and is shared with the other Wemap SDKs.
Requirements
See the common requirements in Getting Started with Wemap SDKs.
Adding a map
Create a MapSession, pass it to a MapView, and add the view:
func showMapView() async throws {
let session = try await MapSession(mapID: 19158, token: "YOUR_TOKEN")
let mapView = MapView(frame: view.bounds, session: session, config: MapViewConfig())
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(mapView)
}
The managers are built while the map loads, so wait for awaitLoaded()
before reaching them:
_ = try await mapView.awaitLoaded()
// now it's safe to access MapView properties
mapView.userTrackingMode = .follow
Reading a manager earlier fails with a message naming the property, rather than an unexplained nil. To observe
loading instead of awaiting it, use loadPhases — a stream of LoadPhase
that replays the current phase.
In SwiftUI, use Map instead — see Using the map in SwiftUI.
User location
By default the map uses Apple's Core Location for raw updates. To use a Wemap positioning source,
attach any LocationSource to the map's UserLocationManager:
mapView.userLocationManager.locationSource = try VPSARKitLocationSource(session: session)
See the positioning guides for details on VPS and GPS.
Examples
For sample implementations, see the official sample-apps repository.