Learn How To Add Google Maps In Android Application Using API | Ashutosh Pawar | Skillshare

Learn How To Add Google Maps In Android Application Using API

Ashutosh Pawar, Software Developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
2 Lessons (12m)
    • 1. Introduction

      1:42
    • 2. Exact Steps To Add Google Maps To Android Application

      10:16

About This Class

In this class we will learn how to add google maps in your android application. We learn how to obtain an API key which allows us to access and display google maps in our android application.

Transcripts

1. Introduction: hello and welcome to the glass, adding Google maps to your android application. So in this class, we are going to learn the exact steps which are required toe. Add Google maps to your android application. So if you want to learn how to add Google maps to your android application, So let's say you have already developed an android application and you need to figure out how to add Google maps to your android app. Or let's say you just want to learn how to create an application which accepts or with shoes, Google Maps. Then this class is perfect for you. So let's go ahead and learn what we're going to design in this class. So we're basically going to add Google Maps by using Android Studio. So and we're Studio is an integrated development environment to make android APs. So we're going to use Android Studio, and we're going to design an application which looks something like this so you could basically enter a location by using the latitude and longitude positions on whichever location you enter. Our APP is going to display that particular location on the map. We are going to learn the exact steps like how to create a project, how to opt in an e p. A key for an application for the Google maps and how to basically ember Google maps into our application on which are the classes and which are the Internet permissions that we need to add in so that our annual application will be able to have an activity off Google maps as shown in the picture. So thank you very much for watching this lecture on in the next lecture. We will learn the exact steps to design the application. So thank you very much for watching on. I'll see you guys in the next lecture. Thank you. 2. Exact Steps To Add Google Maps To Android Application: Hello and welcome to this class on in this class, we will be creating a new android studio project so as to set up an activity for the Google maps. So the very first thing you need to do is that you need to open up Android studio. So if you already have Android studio installed, then you could just open it up. Or you could easily find the installation steps to install Android Studio. If you do a quick search on Google, so once you have the Android story opened up, this is what you get. So the next thing you need to do is that you need to create an option with, say, start a new Android studio project, so simply click on it. And let's name this application as my map application on Let's give it to hear, because I already have on application, which is called last my map application. Now let's click next and make sure that you select the A P A level 15 which is nothing but android 4.0 point three ice cream sandwich, then click next, And actually you could choose any AP level. But the peer level 15 is the most stable and suitable one. So I'm going to choose that now. In this case, what you need to do is start to add an activity. You need to select the Google maps activity, so select activity and click next and let the name off this activity be maps activity and finally hit Finish on. It is going to take a while for your project to load up. So we will continue once the project is loaded up. So as you could see now are Android Project is up and running on Android studio. So right now we have to class two things first is theme APS activity door Java class, in which we will be writing our court on the next thing which we have Is this Google Maps ap i dot xml. So this thing right here, which I have blood, is nothing but the a p I key which we're going to need. So what we actually need to do is that we actually need to generate a key depending upon these credentials. So what you need to do now after after just opening up the android studio, you also need to make sure that you have installed Google Play Services in Android Studio. So in order to make sure that you have installed Google Play Services, you simply go to the SDK manager. Then just click on the launch stand alone as decay manager and it is going to launch. The stand alone is decay manager, and here you could actually verify the packages which you have installed. So if you just minimize the rest of the packages on, if you look for extras, as you could see, this is Google. Play Services on this symbol states that there is an upgrade available, but I have already installed will play services. So if Google play services is not installed on your PC, what you could do is that you could simply check this option on. You could lick on this option with, say's install packages, so you simply need to install Google play services before starting the project. Now, after installing Google play Services, you need to restart enrolled Studio on After the starting on your studio, you could go ahead and create a new project just we have created right now on If in case Google play services is already installed, you could proceed ahead. So the next thing which we need to do is that we need to open up a browser. And here we need to search for something which is called us Google developer Console So hit , Enter and we will level apart. Console is going to open up. So simply open up the Google level upper console. So here you actually need to log in with your Google account. So make sure that you sign in with the Google account and after doing that, you will have an option here. Now, as I already have many keys actually have a name here. But what you could do is that you will simply click here on you could create a new project . So simply select the option with, say, its creator project. And let's name this project as new app for map andan Simply click on, create on it is going to take a while to create a new project. So, as you could see once the project is creator, the name off your newly created project is going to appear here. Now the next thing which you need to do is that you need to goto Google Maps android AP I so simply select this option on after this, you click on enable and this is going to enable the Google Maps Android a beer for this project right here. Now, after doing this, you actually need to create credentials. So click on this button with sales kowtow credentials. So it is going to take you to the credentials on Dhere. You need to choose which ap I we are using. So we are using Google Maps API and we actually you warned this for Android. And when you click on this button, as you could see, it tells us to create an e p I key. So let's say the name of the P I key is this. Now you actually need to our package name and fingerprints. So simply click on this thing right here and here. You need to actually copy and paste the package name. So if you switch back to Android Studio, this thing right here is nothing but your package names. So make sure that you copy this package name right here. So I'm going to simply copy this written back to the global level, a broken soul and based the package name on after this, you need to pace the SST one certificate fingerprint, so the fingerprint is actually available here. So what you need to do is that you simply need to copy this thing written back to Google developer console and placed it over here, and I'm actually going to blood it because I don't want anyone to copy my key. After basting these two things, you could click on this, Create a P I key button on it is going to create an e p a a p a key for you. So this thing right here is the FBI key. So simply copy this AP a key on click done. And as you could see now, your key is actually there. Now, just go to Android Studio and right here of it. Say's Yoki here you need to paste the copied key without having any spaces. So make sure that you delete any species if this thing has any spaces, So after doing that, we are almost done. So the next thing which you need to do is that you need to go to the manifesto. It is right door here, and you need to add in certain permissions so I'm going to add the required permissions. So the first permission which we want for this application to accesses the Internet permission. So I'm going to type and use this permission Internet. So this is the first permission, the next permission, which we want as the access network state. So I'm going to type and use this permission access network state. And then we weren't the access find location, but that permission is already added up all here and then another permission, which we need is access course locations. So I'm going to type in Access Coast location here on. Once we have these permissions, we simply save the court, and then we actually need to run this thing either on the emulator or on an actual device. But even before running that what we need to do is that we need to go to the maps activity door Java file right here on inside the method with stays on my pretty. You actually need to set the latitude and longitude options over here. Now, the by default latitude and long it your is actually said to Sydney. So if you want to set it to some other place Then you could go toe who will search for the latitude and longitude off your desire location and simply pasted over here. Now, after doing that, one more extra line off court which I recommend you toe al, is that you actually need to zoom into a particular locations. So simply type m map dot Any meat Gambetta on inside here. Just typing camera update factory dot Knew lasted you long. It your That is large. Lang, zoom on here. You actually need to specify to which particular position you won't resume it, so you'll be passing the latitude longitude objects. So I'm going to type in Sydney here, and then you need to mention the scale to which you want to zoom. And so I guess 12.0, it's perfect for this. And just type in f or floating on. Once you're done with this, you're good to go. So now what I'm going to do is that I'm going to see if the court on I will try to run this thing on my actual device and show you the results. So, as you could see, I'm recording my screen right now and this is what I get when I actually run my application . So the current marker on the map is pointing towards Sydney, so I will stop recording my phone screen so that so you basically embed or use will map in your android application. So let's say in your android application, for some reason you need to use a Google map on you need to point to a certain location. So what you could do is that after completing this, you could display around with the on my pretty class. You could go ahead, make some modifications, used the latitude and longitude positions off certain other location on. You could also go ahead, and you could also extract values from the database. And you could you start to display multiple markers instead of having a single Marco. So that's it for this class on. I hope you guys understood the steps required to basically embed a Google map into your android application. So thank you very much for watching and have a nice day. Thank you