WEBVTT

00:00.080 --> 00:01.040
Welcome back.

00:01.200 --> 00:10.600
In the previous videos, I said to you that Google offers you a lot of APIs that you can benefit from.

00:10.720 --> 00:19.720
One of those APIs is the Google Maps platform, that geocoding API that we worked with, and the other

00:19.720 --> 00:21.240
interesting APIs.

00:21.400 --> 00:26.520
We're going to deep dive into the places API and directions API.

00:26.880 --> 00:33.440
Let's start with the places API from the console Cloud.google.com.

00:33.480 --> 00:37.440
Select the project and click places API.

00:37.480 --> 00:41.760
Or you can simply search for places API.

00:41.920 --> 00:46.720
This is the main page of the product details that for the places API.

00:47.160 --> 00:50.720
And you notice that the API is enabled.

00:50.720 --> 00:55.120
If it is not enabled, just click enable button.

00:55.320 --> 00:57.400
You can go and manage it.

00:57.400 --> 01:06.080
The Google Places API allows you to integrate location search, autocomplete and the place details into

01:06.080 --> 01:08.280
your Jetpack Compose application.

01:08.480 --> 01:13.000
This is useful for apps that need searching for places.

01:13.000 --> 01:13.880
Example.

01:14.200 --> 01:15.120
Restaurants.

01:15.160 --> 01:16.160
Landmarks.

01:16.280 --> 01:22.680
Autocomplete suggestions like Google Maps search bar and fetching place details.

01:22.720 --> 01:25.800
Name, address, photos and ratings.

01:25.800 --> 01:33.240
So if you are working on a map that requires searching for places, autocomplete suggestions, or even

01:33.240 --> 01:42.000
fetching place details that ratings, photos, address and name, just go and implement the Google Places

01:42.040 --> 01:44.120
API in your application.

01:44.320 --> 01:50.240
Here you can search for places you notice that the places API is enabled.

01:50.240 --> 01:52.440
You can click on for disable it.

01:52.440 --> 01:57.000
You can enable other APIs and search for other APIs.

01:57.120 --> 02:04.720
But till now we are working with geolocation and geocoding application and API and the places API.

02:04.960 --> 02:07.240
Click on keys to get the keys.

02:07.240 --> 02:18.790
And I I said to you that the API keys are shared across the applications and the Google Map APIs.

02:19.310 --> 02:24.550
So if you click on show key, you can go to your manifest.

02:24.550 --> 02:31.190
And notice that it's similar to what we've done before and what we, uh, created before.

02:31.310 --> 02:31.670
Okay.

02:31.710 --> 02:39.110
So the same key is shared across the Google Maps platform geocoding and places API.

02:39.310 --> 02:41.150
This is the first step.

02:41.430 --> 02:50.070
The second step is to implement the places API into your build.gradle file.

02:50.110 --> 02:59.070
Open Build.gradle file and here Make places API annotation implementation.

02:59.230 --> 03:07.190
We need to use Google Android Libraries places API and implement a library.

03:07.390 --> 03:08.430
You can change it to

03:12.390 --> 03:13.750
Point one.

03:14.070 --> 03:15.110
This is good.

03:15.150 --> 03:16.630
This is the latest version.

03:16.630 --> 03:18.590
Always use the latest version.

03:18.670 --> 03:20.110
Click sync now.

03:20.390 --> 03:28.470
The third step is to check that the metadata of the Android API key is implemented in the manifest.

03:28.470 --> 03:31.750
So open the manifest check for the metadata.

03:32.070 --> 03:40.550
The name comes at Google Android dot API key and you set it the value of the API key.

03:40.750 --> 03:46.390
The fourth step is the initialization of place autocomplete.

03:46.430 --> 03:55.310
Okay, so inside your package, create a new Kotlin class named as my application.

03:55.430 --> 04:01.710
This application class extends from application Alt Plus.

04:01.710 --> 04:09.150
Enter to import this class and we need to override the Oncreate function here.

04:09.150 --> 04:18.820
Initialize the places API places dot, initialize and pass the application In context, the first parameter

04:18.820 --> 04:22.460
and the second parameter is the API key here.

04:22.660 --> 04:30.100
Go to the androidmanifest, copy it or you can directly extract it from the show key.

04:30.140 --> 04:31.820
From here paste it.

04:31.820 --> 04:34.940
And this is the fourth step.

04:35.060 --> 04:38.580
We need to, uh assign it inside the manifest.

04:38.580 --> 04:49.020
So here inside the activity or inside the application scoop and tag create name and set it to my app.

04:49.020 --> 04:59.980
Why we create this application class in order to initialize the places API and the places class whenever

04:59.980 --> 05:02.820
the app first start and run.

05:02.860 --> 05:03.380
Okay.

05:03.420 --> 05:12.020
So whenever you run the application places API will be initialized and the places class will create

05:12.020 --> 05:14.620
it and create an instance from it.

05:14.660 --> 05:15.180
Okay.

05:15.420 --> 05:22.100
This is a very important step in order to make everything work fine and smooth.
