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 shapes


Google Maps for Android allows us to add custom shapes in our map application. The three ways supported are as follows:

  • Polyline

  • Polygon

  • Circle

Let's understand these methods now.

Polyline

Polyline is a set of points where line segments are drawn between consecutive points. For example, you can give a set of latitude, longitude coordinates as input, and lines are drawn connecting these points.

The following image is an example of a polyline that connects two points:

The Polyline object consists of a set of latitude, longitude coordinates and it connects the points to each other.

Creating a polyline

A polyline can be created using a PolylineOptions object. By calling the add() method on the PolylineOptions object, you can add latitude, longitude coordinates to the polyline. The add() method takes the LatLng object as a parameter. The polyline can be added to the Google map by calling the addPolyline() method on the GoogleMap object, which takes the PolylineOptions object as a parameter...