How to Implement Google Maps in Android

In this tutorial we are going to learn to implement google maps in android. We might need maps in our application to show a store or place on map so that user can navigate to that specific place. If you are planning something big say you want to design app like uber or ola then integrating map is first priority so that we can show location of your car.

So to build google maps is not a big task. But first we need API key for google maps. To get this API key follow the below steps.

Creating API key

  • To get our API key we have to first login to Google API’s console.
  • Sign in here android create your project by clicking on the marked area from below image.google maps androidgoogle maps android
  • Once your project is created go ahead and select Maps SDK for android. You can select this by selecting Library API and then select Maps SDK for android.
    google maps android
  • After selecting Maps SDK for android then you will be redirected to page with SDK detail. Here we have to enable it.
  • After successfully enabling it we will be redirected to dashboard.
  • On dashboard click on credentials.
  • On credentials page we will be asked to create key. Hit on that and your key will be generated. Your key will start with “AIza”.
    google maps android

Building Android Application

  • The main in building google maps is UI. Where you can render map. Here we are using fragment element to render map.

     
  • Now we have to add our key in values folder (Better implementation). Create new xml file in values folder. Then add your API key as below.

     
  • Now build your java class and connect our user interface. Which will look like this.

     
  • Now extent our class FragmentActivity and also implements to OnMapReadyCallback and add the override function of same.

     
  • Adding whole code in MainActivity.java.

     

That’s it guys now our google maps is ready. If you have any query then please do comment down below and I will be happy to help you. Thank you 🙂  ……

 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.