Working with UI controls
The Google map's API provides some inbuilt UI controls to make our task easier. The UI controls that can be enabled or disabled are as follows:
Zoom controls
Compass
My Location button
Level picker
Let's learn about these UI controls in more detail.
Zoom controls
Zoom controls are normally used for zoom-in and zoom-out functions. These buttons are disabled by default. The new version of the Google Maps application has removed these controls. It is up to you to display or disable them in your application.
These zoom controls are enabled or disabled using the UiSettings
class, which can be obtained by calling the getUiSettings()
method on the GoogleMap
object. Then, call the setZoomControlsEnabled()
method on the obtained UiSettings
class, which takes a Boolean value as a parameter. The true
parameter indicates that zoom controls should be displayed.
Let's now code for this requirement.
The layout code for MapsActivity
is as follows:
<?xml version="1.0" encoding="utf-8"?>...