Book Image

Learning Android Google Maps

Book Image

Learning Android Google Maps

Overview of this book

This book helps you to overcome the most common problems faced by users and helps you create a successful map application without any hassle. The book starts with a brief description of how to set up an environment and obtain an API key to create your map application. This book will teach you about adding markers, overlays, and information windows to the map in detail. You will then dive deep into customizing various types of maps and working with location data and Google Street view. By the end of this book, you will be able to create succinct map applications in Android using Google maps efficiently.
Table of Contents (18 chapters)
Learning Android Google Maps
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

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"?&gt...