Guide to Include Google Maps API in Android Studio project

Wouldn’t it be nice if you could include the original and well popular ”Google Maps” in your Android app ? A quick , few simple steps can enable maps in your Android Studio project, and make your app facilitate to GPS, navigation , Location data and lots more.

Stop thinking from where Google Maps comes from, young developer. Generate an Google Maps API id and attach it to your project at the required file. The Google Maps is all yours to develop. Check out the following steps:

Steps to include Google Maps:

Creating a new Map Activity:

Open Android Studio. Give a suitable application name of your choice. Click next and select GoogleMaps Activity from the activity options list. When you click finish, And get the gradle build finished the output  google_maps_api.xml will look like this.

Screenshot from 2016-10-13 13-16-55

Enabling Google Maps API:

Copy the highlighted URL in the above picture onto your browser. You’ll reach the official site of Google API credentials.

Screenshot from 2016-10-13 13-20-23

Click Continue. Wait for the API to become enabled. After the API is enabled, a new screen will pop up like this to generate the required API key.

Screenshot from 2016-10-13 13-22-28

Click Create API key button. An API key will be generated to incorporate Google Maps in your developing Android application.

Copy the generated ID and paste the key in “YOUR KEY HERE” in google_maps_api.xml. This will make the Google Maps function .

Screenshot from 2016-10-13 13-17-33

Setting a marker (location):

Open the from the main tab.

Screenshot from 2016-10-13 13-18-04

In the onMapReady() there is a default marker setting as Sydney. You can change this marker according to your desired loaction.

Give the desired lattitude and logitude in the LatLng() function. You can specify your location in the position() function. Add any text to the marker if necessary in the text portion,

I’ve developed a sample , where the marker is at the location of Taj Mahal, Agra, India.

WhatsApp Image 2016-08-24 at 8.59.44 PM

Hope you guys will try it out..!!:) Happy learning..!!