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

Implementing different types of maps


Make sure you have registered your application in the Google Developer Console and obtained the API key for it. Then, set up Google Play services and define the API Key in manifest. Now, let's see how to implement different types of maps in our application.

Create a new Android application in Eclipse or Android Studio. Let's see the code needed for a layout file. The easiest way to load a map is using a MapFragment class. The code for the layout is the same as the one we used in the previous chapter:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"/>

activity_maps.xml

Using a normal map

The first step is to initialize a GoogleMap object. Then, we should call the setMapType() method on the GoogleMap...