Location indicator
Show and style the device's current location on the map.
Overview
Enabling the user location indicator renders a view on the map showing the device's current
location. This is a WemapMapSDK feature.
Enable the default indicator by setting a user tracking mode:
mapView.userTrackingMode = .follow // or .followWithHeading
Customizing the appearance
Customize the indicator through mapView.userLocationManager.userLocationViewStyles:
mapView.userLocationManager.userLocationViewStyles = .init(
normal: .init(
foregroundColor: .green,
backgroundColor: .white,
headingColor: .red
),
stale: .init(
foregroundColor: .brown,
backgroundColor: .white,
headingColor: .cyan
),
outOfActiveLevelOpacity: 0.4,
accuracyColor: .green,
accuracyAlpha: 0.2,
pulseEnabled: true,
pulseColor: .magenta,
pulseAlpha: 0.3
)
The normal and stale styles are WemapMapSDK/UserLocationViewStateStyle values — stale is used when
location updates go quiet (see WemapMapSDK/MapViewConfig/staleStateTimeout).
Which of the two is in force is WemapMapSDK/UserLocationManager/locationState, and
WemapMapSDK/UserLocationManager/locationStates reports every change to it. Follow them when your own UI
repeats the user's position — a floor indicator, a recentre button — so that it greys with the puck instead of
claiming a position the map no longer trusts. The stream does not replay, so seed from the property first:
var isStale = mapView.userLocationManager.locationState.isStale
for await state in mapView.userLocationManager.locationStates {
isStale = state.isStale
}