Skip to main content
Version: 1.x (beta)

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 WemapMapSDK/MapSession, which loads the map's data once and is shared with the other Wemap SDKs.

Requirements​

See the common requirements in Getting started.

Adding a map​

Create a WemapMapSDK/MapSession, pass it to a WemapMapSDK/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 WemapMapSDK/MapView/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 WemapMapSDK/MapView/loadPhases — a stream of WemapCoreSDK/LoadPhase that replays the current phase.

In SwiftUI, use WemapMapSDK/Map instead — see SwiftUI guide.

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 WemapMapSDK/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.