Welcome back.
In the previous videos, I said to you that Google offers you a lot of APIs that you can benefit from.
One of those APIs is the Google Maps platform, that geocoding API that we worked with, and the other
interesting APIs.
We're going to deep dive into the places API and directions API.
Let's start with the places API from the console Cloud.google.com.
Select the project and click places API.
Or you can simply search for places API.
This is the main page of the product details that for the places API.
And you notice that the API is enabled.
If it is not enabled, just click enable button.
You can go and manage it.
The Google Places API allows you to integrate location search, autocomplete and the place details into
your Jetpack Compose application.
This is useful for apps that need searching for places.
Example.
Restaurants.
Landmarks.
Autocomplete suggestions like Google Maps search bar and fetching place details.
Name, address, photos and ratings.
So if you are working on a map that requires searching for places, autocomplete suggestions, or even
fetching place details that ratings, photos, address and name, just go and implement the Google Places
API in your application.
Here you can search for places you notice that the places API is enabled.
You can click on for disable it.
You can enable other APIs and search for other APIs.
But till now we are working with geolocation and geocoding application and API and the places API.
Click on keys to get the keys.
And I I said to you that the API keys are shared across the applications and the Google Map APIs.
So if you click on show key, you can go to your manifest.
And notice that it's similar to what we've done before and what we, uh, created before.
Okay.
So the same key is shared across the Google Maps platform geocoding and places API.
This is the first step.
The second step is to implement the places API into your build.gradle file.
Open Build.gradle file and here Make places API annotation implementation.
We need to use Google Android Libraries places API and implement a library.
You can change it to
Point one.
This is good.
This is the latest version.
Always use the latest version.
Click sync now.
The third step is to check that the metadata of the Android API key is implemented in the manifest.
So open the manifest check for the metadata.
The name comes at Google Android dot API key and you set it the value of the API key.
The fourth step is the initialization of place autocomplete.
Okay, so inside your package, create a new Kotlin class named as my application.
This application class extends from application Alt Plus.
Enter to import this class and we need to override the Oncreate function here.
Initialize the places API places dot, initialize and pass the application In context, the first parameter
and the second parameter is the API key here.
Go to the androidmanifest, copy it or you can directly extract it from the show key.
From here paste it.
And this is the fourth step.
We need to, uh assign it inside the manifest.
So here inside the activity or inside the application scoop and tag create name and set it to my app.
Why we create this application class in order to initialize the places API and the places class whenever
the app first start and run.
Okay.
So whenever you run the application places API will be initialized and the places class will create
it and create an instance from it.
Okay.
This is a very important step in order to make everything work fine and smooth.