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

Map padding


In general, Google Maps fills the entire container and its controls are displayed at the edges. They are as follows:

  • Zoom controls are displayed in the bottom right corner

  • My location button is displayed in the top right corner

  • Compass controls are displayed in the top left corner

Other than these, the Google Maps copyright information is displayed in the bottom-left corner.

There may be situations where you may have to display other information in place of these elements. To make this possible, you can pad the elements in the corners.

This can be done by calling the setPadding() method on the GoogleMap object. It takes pixels as an integer value to pad the left, top, right, and bottom edges.

It would be called as follows:

        map.setPadding(400, 100, 100, 0);

This means that 400 pixels are padded in the left corner and 100 pixels are padded in the top and right corners.

Let's discuss this with an example. The code for the layout remains the same as we used in the beginning with MapFragment...