Map Widgets Getting Started
Add the levels rail, the itinerary form and the points-of-interest sheet to a Wemap map, in SwiftUI or UIKit.
Overview
WemapMapWidgetsSDK is the map controls you would otherwise write yourself — the levels rail, the itinerary
form that plans a route across the map, and the sheet that lists the map's points of interest — styled the way
the Wemap design is on the web, Android and Flutter, and driven by values rather than by the SDK's managers.
Requirements
See the common requirements in Getting Started with Wemap SDKs. The widgets ship from their own package on a 0.x version line,
Swift Package Manager only — its Map widgets section says how to add them. The points-of-interest sheet and its
hosts need iOS 16.4; the rest of the widgets, and PointOfInterestList on its own, need
iOS 15.
Switching levels
The quickest way in is the modifier on Map, which wires the focused building and the active level
for you:
import WemapMapSDK
import WemapMapWidgetsSDK
Map(session: session)
.levelsSwitcher()
The rail also marks the level the user is standing on with a dot, which pulses while their position is being
updated and becomes a static ring once the map stops trusting it — the same moment the location indicator greys.
Pass showsUserLevel: false to leave it out.
Every widget is also a plain SwiftUI view over values, so it can be placed anywhere, previewed, and driven from state you already have:
LevelsSwitcher(levels: building?.levels ?? [], selection: $level, userLevels: userLevels)
Planning an itinerary
itineraryForm(isPresented:alignment:destination:searchesPointsOfInterest:travelMode:isWheelchairAccessible:itineraryOptions:fitsCamera:camera:style:pickerStyle:pointOfInterestListStyle:onItineraries:onFailure:)
puts an ItineraryForm over the map and wires the whole flow behind it — resolving each end,
computing the itinerary and drawing it:
Map(session: session)
.itineraryForm(isPresented: $planningItinerary)
There is no compute button, because there is nothing to submit: the form is the request. Setting either end, flipping the wheelchair switch or swapping the two recomputes the itinerary and redraws it.
Each end is filled from the user's position, by picking a point on the map — which replaces the card with a
MapPointPicker and a pin at the map's centre — or by typing: the card lists the map's points
of interest that match, and a tap fills that end. Both ends can be filled by hand, so the form works on a
screen with no location source at all — the user's position is the shortcut, not the way in, and it resolves only
while something on the screen already has location running. Pass searchesPointsOfInterest: false to keep the
fields tap-only.
When the user arrives from a point of interest they already chose, seed the end they are heading for:
Map(session: session)
.itineraryForm(
isPresented: $planningItinerary,
destination: ItineraryEndpoint(poi)
)
Planning from an itinerary already on screen — a route back from where the last one arrived — goes through
init(_:fallbackName:), which takes either end of a computed
Leg:
.itineraryForm(
isPresented: $planningItinerary,
destination: ItineraryEndpoint(leg.start, fallbackName: "Where I started")
)
If this screen binds the camera with camera(_:frequency:), pass that binding as
camera: — a bound camera is the live source of truth and SwiftUI re-applies it over the framing otherwise.
And a map that is following the user re-centres on the next fix, so stop following before you present the
form.
Listing points of interest
pointOfInterestList(detent:selection:sorting:rowContent:style:tagFilterStyle:onSelect:)
puts a PointOfInterestSheet along the bottom of the map. It is the system's sheet, resting
collapsed, half open or fully open, and it lists what the map shows: every point of interest the map downloaded
and those you added, minus the ones hidden or filtered out, following the map as that changes.
Map(session: session)
.pointOfInterestList()
Its search field narrows the list by name, address, description and tag, ignoring case and accents. Once the user pauses typing, the map narrows too: it draws only the matches and the selected point of interest, also while the sheet is collapsed, whose bar then shows the query with a button to clear it.
When the map's tag configuration is active, a filter button in the bar opens a panel of the map's tags by
category, and the featured ones show as chips under the search field. The tags picked narrow the map and the list
together, through tagFilter, combined as the map's configuration says.
Both the search and the tag filter are lifted while the sheet is off screen, and applied again when it returns.
tagFilterStyle: restyles the panel and its chips, like style: does the sheet.
Tapping a row highlights it and reports it — the list moves nothing on the map, so what a pick does is yours to decide. Here it plans a route there with the itinerary form, sorts the rows by the route from the user, and collapses the sheet so the form is not under it:
Map(session: session)
.pointOfInterestList(detent: $detent, sorting: .graphDistance) { poi in
destination = ItineraryEndpoint(poi)
planningItinerary = true
detent = .collapsed
}
.itineraryForm(isPresented: $planningItinerary, destination: destination)
graphDistance asks the router only while the sheet is open, and
again each time the user moves ten metres or changes floor; until the map knows where the user is, the rows are
by name. PointOfInterestRowContent chooses what each row shows under the name.
The sheet is presented rather than drawn over the map, so it covers every other widget whatever the
order of the modifiers — collapse it, through detent, when another widget needs the lower half of the screen.
While it is up, what you present with SwiftUI — an .alert, a .sheet — shows over it with nothing to do, as
seen on iOS 27; a UIKit screen presents from the sheet instead, see
PointOfInterestListController.
UIKit
UIKit screens get the same widgets through host controllers, which mirror the SDK's state and size themselves. Create them once the map has loaded, since the managers do not exist before then:
_ = try await mapView.awaitLoaded()
let levels = LevelsSwitcherController(
buildingManager: mapView.buildingManager, userLocationManager: mapView.userLocationManager
)
levels.attach(to: self, in: mapView, alignment: .trailing)
ItineraryFormController is the itinerary form's counterpart:
let form = ItineraryFormController(mapView: mapView, onClose: { [weak self] in self?.form?.detach() })
form.attach(to: self, in: mapView, alignment: .top)
attach(to:in:alignment:) places a widget exactly where the SwiftUI modifier places it —
edgeSpacing in from the container's safe area — and never gives the card a
height, which follows the form as it grows and shrinks. For any other placement, attach(to:in:) does the
child-controller bookkeeping alone and leaves the constraints to you.
Dismissal is yours on this path, since there is no isPresented to write:
detach() takes the card and the pin off the map and removes the
itinerary the form drew.
PointOfInterestListController presents the points-of-interest sheet from your screen:
let list = PointOfInterestListController(mapView: mapView) { [weak self] poi in
self?.showDetails(of: poi)
}
list.attach(to: self)
A presentation outlives the screen that made it. Detach the sheet before you navigate away —
viewWillDisappear(_:) is the usual place — or it stays up over the next screen.
Placement
levelsSwitcher() puts the rail edgeSpacing from the edge you align it to,
which is all most screens need. When that edge is already busy — your own locate-me button, a bottom sheet, or
MapLibre's attribution button, which sits in the bottom-trailing corner — take the placement over with the closure
form and inset it yourself:
Map(session: session)
.levelsSwitcher(alignment: .bottomTrailing) { rail in
rail.padding(.trailing, 8).padding(.bottom, 88)
}
The closure receives the wired rail and returns whatever goes over the map, so it can decorate as well as inset;
edgeSpacing is the inset the default placement would have applied, if you want
to match it. itineraryForm has the same pair of entry points, and its closure receives whichever card is on
screen — the form, or the picker while a point is being chosen.
The host modifiers return the map, so they compose with each other and with the map's own modifiers in any order:
Map(session: session)
.levelsSwitcher()
.itineraryForm(isPresented: $planning)
.camera($camera)
Styling
A widget takes its colours, fonts and radii from the WidgetTheme in the environment, so
one modifier restyles every widget on a screen at once:
Map(session: session)
.levelsSwitcher()
.wemapWidgetTheme(WidgetTheme(primaryColor: .accentColor, surfaceCornerRadius: 20))
Pass a per-widget style — LevelsSwitcherStyle, ItineraryFormStyle,
MapPointPickerStyle, PointOfInterestListStyle — when one control
needs to differ from the rest.