Getting Started with Google Maps APIs in Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey how's it going guys in this video i want to cover how to use google maps api service in python alright so google maps service is probably the most widely used online map service so pretty much everyone have used google maps at some point and the google maps api platform has actually quite many services that you can use so in this video i want to cover some of the most important things uh in this video as well as how we can use google maps api services in python so let's start with uh the google maps api platform i'll go straight to the point so if you go to developers.google.com slash maps slash documentation here let me go to the documentation page and right away you're going to see uh the maps platform offers quite many different services yeah i think this way a lot of people got scared because they don't know which one to use and to be honest i haven't found many good information with it online i want youtube covers at least a good amount of information when it comes to using google maps platform in paisa so when it comes to google maps platform we have different different categories of services that we can use we have routes which covers these three api services directions distance matrix api which calculate the travel times between two places or multiple places and rows api which provides you with the map direction and we have places a category not api places category and the places category will have these numbers of google maps api services industry solutions are basically use cases and the maps category i think this one is the most widely used category now let's cover on the pricing i think this one the most important aspect when it comes to using google maps service so google maps api is actually pretty expensive but fortunately with google maps api service google will give you 200 free credit every month so you can use up to 200 worth of service users after that you have to pay based on the service that you're using then the pricing table will be a little bit different so here let's go down to pricing for the map services so have static maps and for mobile's free assume because google is trying to collect information from mobile users when it comes to study the behavior on how users use google maps on the mobile device and these are other apis that you can probably go to an information let's take a look look at the routes so graphs is a little more uh expensive than the other two categories just because um browse requires uh live data from google server so if we see the pricings for dimensions is five dollars per one thousand crisis for the speed limit so right now this one is new right now you can use google maps apis to determine the speed limit of certain rows of certain places and the api causes 20 per 1000 elements and then we have places i think this one is also pretty expensive and that's for the pricing now i want to cover how we can use google maps api service in python now let's go to documentation under documentation let's go to one of the uh apis that the google map python client supports and no distance matrix api is one of them so let's go into that if i want to use google maps api there are two different methods one is two web services which is what google prefers basically you're just passing a url and making a request code and the other method is we can use google maps sdk all client libraries and the client libraries currently supports java python go and node.js and these are the seven api services that the google maps client supports so division api is the matrix elevation geocoding places rows and time zone and for all the api services that are not including this list then you'll have to make a web code using the requests library now we know what api services the google map client library supports now let's go into our google cloud console so before we can use those services we need to enable the api so under the navigation menu go to apis and services and go to library i know the easiest api to use is geocoding so i'm going to search for geocoding api and go into the service and make sure that the api service is enabled if i'm using other services such as distance matrix api then you will have to enable those api services individually here let me just enable the api service once we enabled the google maps apis want to use now we need to get the api client key so unfortunately you cannot use op2 authentication method to access the api you have to provide an api key to create or if they have an api key created you can go to navigation menu apis and services go to credentials under the api keys so here i'm going to copy my api key so let's grab the api key and paste into our python script so here they have a script created i'll name this api key api key uppercase so here i'm going to import the library by typing import google maps and if you don't have the library uninstalled you can use the command pip install oops pip install google maps face straight forward and to construct google map client object from the google maps library want to reference dot client uppercase c so i want to access this method and we just need to provide the api key and we'll name the output map client now if i highlight these two lines and run it and if i use the the function to print the attributes and methods of the map client object if we look at this list so here from the map client object we can now access these numbers of api services so geolocated geocode find place directions uh distance matrix so that's the one we're looking at elevation api service now i'll give you an example on how we can use the map client object to use let's do let's use geocoding service so geocode so we'll use this service and with the mac client object so from map client option want to reference geo code and that's the api service i want to use and the geo code service requires an address so here let's create an address and here i'll create a variable code we'll place address now insert my old workplace address one mark history in san francisco california it will pass this address to the geocode method oh and here let me import the pp print function because the response is not going to be pretty and let me input the function first i'll name the output response now if i highlight these two lines and run it i'll print the response option by using the pp print function and based on the response option so here's the result with the geocode api service we will have address component so the first component is the uh is the address number street name self speech is actually a neighborhood name right here so it gives the type and stream number and route is just the street name cd and so on and if i want to grab the geocode i need to reference the jama tree key if you notice that the response object it should return as a list so we need to oops it should be so here i'm going to use the print function i'll insert the response option and it's going to be the first tracker so i don't know why google makes these alerts i think because later on with newer updates of newer version we can finally insert multiple locations or addresses right now i know for fact that we can only insert one address at a time now i want to reference the first record and followed by the key value so it's going to be geometry and if i run line 11 that'll print the location value from the value will have ladder to longer to value location type field so that just means that these are the corners facing different uh directions so this if someone to cover in this video and hopefully you guys found this video useful
Info
Channel: Jie Jenn
Views: 91,608
Rating: undefined out of 5
Keywords:
Id: HChq5_7yTGk
Channel Id: undefined
Length: 10min 50sec (650 seconds)
Published: Mon Nov 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.