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 the Android Location API


The Android framework has an inbuilt android.location package, which helps us retrieve the user's current location.

It can be implemented by using the LocationListener interface. It provides four methods. They are:

  • onLocationChanged()

  • onStatusChanged()

  • onProviderEnabled()

  • onProviderDisabled()

The onLocationChanged() method is called when the location is changed (when the user moves). The onStatusChanged() method is executed when the status of the provider is changed (the provider may be unavailable initially and available after some time). The onProviderEnabled() and onProviderDisabled() methods are called when the location provider is enabled and disabled.

Then, we should use the LocationManager class to get access to the system's location services. This class can be instantiated by:

LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

Here, locationManager is the object created from the LocationManager class. The getSystemService...