Map Control Buttons
The LazarilloMap includes built-in control buttons for zoom in, zoom out, and current location. These buttons are automatically configured and functional:
Default Behavior
- Zoom In Button: Increases the map zoom level by 1, respecting the maximum zoom limit set in the configuration
- Zoom Out Button: Decreases the map zoom level by 1, respecting the minimum zoom limit set in the configuration
- Current Location Button: Centers the map on the user’s current location (if location tracking is enabled)
Custom Listeners
You can also set custom listeners for these buttons:
// Custom listener for the current location button with result information
lzMap.updateOnMyLocationButtonClickListener { result ->
if (result.success) {
result.location?.let { location ->
Toast.makeText(
context,
"Map centered at: ${location.latitude}, ${location.longitude}",
Toast.LENGTH_SHORT
).show()
}
} else {
Toast.makeText(
context,
"Error: ${result.error}",
Toast.LENGTH_SHORT
).show()
}
}
// Custom listener for marker clicks
lzMap.updateOnMarkerClickListener {
// Your custom logic here
println("Marker clicked")
}Button Visibility
You can control the visibility of these buttons through the LazarilloMapConfig:
val lzMapConfig = LazarilloMapConfig()
lzMapConfig.apply {
hideZoomIn = false // Show zoom in button
hideZoomOut = false // Show zoom out button
hideZoomToLocation = false // Show current location button
}The buttons will automatically animate the camera when pressed, providing a smooth user experience.
Last updated on