Location Component (User Position Marker)
The SDK automatically manages the user’s location marker on the map. This marker shows the user’s current position and is intelligently handled for both indoor and outdoor scenarios.
Enabling Location Tracking
Why two-step setup: The location provider must be set before enabling the location component. This separation allows you to configure the location provider (GPS + beacons) independently from the map’s location display.
Why RoutingStatusRepository: This repository combines GPS and beacon location sources, provides navigation status (on-route, off-route), and emits location updates. It’s the bridge between location hardware and map display.
// Step 1: Set the location provider (combines GPS + beacons, provides navigation status)
// This should be created once and reused
val locationProvider = RoutingStatusRepository(
locationRepository = locationMergedRepository,
externalScope = lifecycleScope
)
lzMap.setLocationProvider(locationProvider)
// Step 2: Enable location component (displays user position on map)
// The location provider must be set first
lzMap.toggleLocationComponent(true) {
// Optional callback when location component is activated
println("Location tracking started")
}Indoor Location Behavior
For indoor locations, the user marker has special behavior:
- Same floor: Marker is visible when user is on the currently displayed floor
- Different floor: Marker is hidden when user is on a different floor
- Outdoor: Marker is always visible for outdoor locations
Troubleshooting Location Issues
If the user location marker doesn’t appear:
-
Check LocationComponent status:
// The SDK automatically checks if LocationComponent is ready // and attempts to reactivate it if needed -
Verify position repository:
// Ensure position repository is set before enabling location if (positionRepository != null) { lzMap.setLocationProvider(positionRepository) lzMap.toggleLocationComponent(true) } -
Check floor matching:
// For indoor locations, ensure the user is on the displayed floor // The SDK automatically handles this, but you can manually check: val currentFloor = lzMap.currentShowingFloor val userFloor = userLocation.floor
Location Component Events
The SDK tracks location component events for debugging:
toggleLocationComponent: When location component is enabled/disabledtoggleLocationComponent_error: When there are errors with the location providerfollowUserLocation: When user location following is toggled
These events help identify issues with location tracking and can be monitored for debugging purposes.