Step by Step Google Maps Implementation in Android App

Google Maps Implementation in Android App

Do you want to add an interactive map to your Android app? Well, you’re in luck! In this tutorial, we’ll guide you through the simple process of Google Maps Implementation in Android App.

Now, we will create an android application. Then, we will create modern dashboard UI in Android app.

  1. Open Android Studio.
  2. Go to File => New => New Project. Write application name. Then, click next button.
  3. Select minimum SDK you need. However, we have selected 21 as minimum SDK. Then, click next button
  4. Then, select Empty Activity => click next => click finish.
  5. If you have followed above process correctly, you will get a newly created project successfully. However, you can also visit post to create a new project to know steps in detail.

Now let’s set up the groundwork. Make sure you have added the below necessary dependency in your build.gradle.

 

Now you will need Google Maps API key, watch below video for creating Google Maps API key.

Once you create your Google Maps API key then copy your key and add it in project AndroidManifest.xml file inside the application tag like below.

 

After adding API key go to your activity_main.xmlĀ and paste the below code.

 

Now open your MainActivity.java and paste the below code inside your onCreate() method and make sure you MainActivity.java implements OnMapReadyCallback.

 

The code snippet aboveĀ finds the MapFragment in your layout and sets it up for asynchronous loading. Now, let’s handle the map when it’s ready. The onMapReady method is called when the map is ready to be used.

In the onMapReady method, we initialize the GoogleMap object and set up a marker at a specific location (Sydney, in this case). The camera is then moved to focus on that location.

Once all the steps are done run your application and you will get the Google map on your application screen.

Changing the Map Marker Color

If you want to change the marker color on map, so make below changes in your onMapReady() method.

 

After these changes in your onMapReady() method the map marker color will be change to green, you can also select any color you want.

Written by Hilal Ahmad

Leave a Reply

Your email address will not be published. Required fields are marked *