Camera Controls
The LazarilloMap provides methods to control the camera’s pitch (inclination) and bearing (rotation):
Setting Pitch (Inclination)
// Set the map pitch to 45 degrees (inclined view)
lzMap.setPitch(45.0)
// Set the map pitch to 0 degrees (top-down view)
lzMap.setPitch(0.0)
// Set the map pitch to 60 degrees (highly inclined view)
lzMap.setPitch(60.0)Setting Bearing (Rotation)
// Set the map bearing to 0 degrees (north up)
lzMap.setBearing(0.0)
// Set the map bearing to 90 degrees (east up)
lzMap.setBearing(90.0)
// Set the map bearing to 180 degrees (south up)
lzMap.setBearing(180.0)
// Set the map bearing to 270 degrees (west up)
lzMap.setBearing(270.0)Following User Location
Why location following matters: During navigation, users expect the map to automatically follow their position, keeping them centered and oriented. This provides a seamless navigation experience without manual map manipulation.
Why pitch and zoom matter:
- Pitch (45 degrees): Angled view provides better forward visibility, showing what’s ahead during navigation
- Zoom (18.0): Close zoom shows street-level detail needed for turn-by-turn guidance
- Padding: Offsets user position to avoid UI elements (e.g., bottom padding for navigation instructions)
Automatic reactivation: If trackingConfig.enableReactivation is true, tracking automatically reactivates after zoom changes, preventing accidental deactivation.
// Start following user location with custom pitch and zoom
// This is essential for navigation apps
lzMap.followUserLocation(
value = true,
pitch = 45.0, // Inclined view while following (better forward visibility)
zoom = 18.0, // Zoom level while following (street-level detail)
padding = doubleArrayOf(0.0, 0.0, 200.0, 0.0) // Bottom padding for UI elements
)
// Stop following user location (user wants to explore map manually)
lzMap.followUserLocation(false)Getting Current Camera Position
// Get the current camera position
val currentPosition = lzMap.getCameraPosition()
// Access individual properties
val currentZoom = currentPosition.zoom
val currentPitch = currentPosition.tilt
val currentBearing = currentPosition.bearing
val currentTarget = currentPosition.targetThese camera controls allow you to create dynamic and engaging map experiences for your users.
Last updated on