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"/> ...

Get Learning Android Google Maps now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.