WEBVTT

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

00:01.320 --> 00:05.200
We created the fetch current location function.

00:05.200 --> 00:11.800
Now let's move up in order to pass those two parameters and call this function here.

00:11.800 --> 00:18.520
Inside the is granted, we need to pass two parameters for the fetch current location.

00:18.560 --> 00:23.200
Pass the context object and on location fetched callback.

00:23.600 --> 00:30.880
This is the location which is the the parameter of the lambda expression.

00:30.880 --> 00:34.280
And here what we need to do on the location fetched.

00:34.320 --> 00:42.160
We need to update my location variable to the newly created location or the newly fetched location.

00:42.200 --> 00:52.160
Okay, so here I am updating my location variable to the recently and and current location fetched.

00:52.200 --> 00:57.280
Then we need to request the permission when composable is first launched.

00:57.480 --> 01:05.850
So launched effect unit location permission launcher dot launch and Android manifest permission access

01:05.850 --> 01:07.250
file location.

01:07.250 --> 01:10.050
Go to Android Manifest here.

01:10.050 --> 01:11.490
Please pay attention.

01:11.490 --> 01:17.370
You need to use the access course location and access file location.

01:17.570 --> 01:23.170
Add those permissions in order to get the latest and the current location.

01:23.290 --> 01:33.090
Then we can enable in Google Maps my location button enabled equals to true in order in the map UI settings

01:33.090 --> 01:36.850
in order to get the current location button enabled.

01:36.890 --> 01:45.970
Now, if we get the current location, what we need to do inside the scope of the Google map, here

01:46.090 --> 01:52.370
we can create a marker, a circle, anything around the location.

01:52.370 --> 01:55.890
So here fetching current location.

01:55.930 --> 02:01.890
My location dot let current location val.

02:02.090 --> 02:08.500
We need to get the lat long so we are getting the and transforming.

02:08.660 --> 02:14.260
Transforming a location object into lat long object.

02:14.260 --> 02:23.140
So here we can get the latitude and longitude and store them inside the newly created current location.

02:23.140 --> 02:30.260
Lat long current location dot latitude and current location dot longitude.

02:30.300 --> 02:33.700
Okay, I'm transforming the location.

02:33.700 --> 02:40.420
It's of type location to lat long and store it inside current location.

02:40.460 --> 02:51.100
Okay, now let me add a marker at current location marker marker set the state position equals to current

02:51.100 --> 02:52.020
lat long.

02:52.180 --> 02:56.220
Set the title, current location and a snippet.

02:56.260 --> 02:57.500
You are here.

02:57.540 --> 02:58.660
Let me add the.

02:58.660 --> 03:04.020
For example a shape circle around the location.

03:04.060 --> 03:08.140
Add a circle around the location Circle.

03:08.180 --> 03:10.260
Center left current.

03:10.300 --> 03:12.660
Left long radius.

03:12.700 --> 03:14.900
For example 200m.

03:14.940 --> 03:16.540
Fill color.

03:16.580 --> 03:20.660
Let's make it blue and make it 20% visible.

03:20.700 --> 03:22.260
Stroke color.

03:22.300 --> 03:23.420
Make it white.

03:23.460 --> 03:25.900
Okay, let me run our application.

03:26.420 --> 03:34.580
Did you notice that a request permission launcher allow maps app to access this device location while

03:34.580 --> 03:35.620
using the app?

03:35.980 --> 03:44.060
So here we allow the user and we allow the app to use the permissions and the device permissions.

03:44.100 --> 03:44.620
Okay.

03:44.780 --> 03:46.940
Let me check the current location.

03:46.940 --> 03:49.980
And here is the marker that we created.

03:50.060 --> 03:54.340
Um you can notice this is the current location.

03:54.340 --> 04:01.660
If I zoom in, you notice the circle that I drew on 200m.

04:01.940 --> 04:04.100
And this is our current location.

04:04.100 --> 04:11.270
You can customize the current location by clicking on this three dots extended controls.

04:11.270 --> 04:13.350
Then go to location.

04:13.550 --> 04:20.670
And here you can get the current axis and the and the current position.

04:20.910 --> 04:26.270
So let me make it um in in Europe or in Brazil.

04:26.710 --> 04:31.430
So let me check put the current location in Brazil.

04:31.550 --> 04:32.510
It's good.

04:32.790 --> 04:34.910
So set the location.

04:34.910 --> 04:36.510
We are in Brazil now.

04:36.630 --> 04:41.910
If I run the application again, we get a location.

04:41.950 --> 04:47.390
Maybe we need to wipe the data from device manager.

04:47.750 --> 04:48.790
Wipe data.

04:49.070 --> 04:53.990
So, uh, you can get and change the current location.

04:53.990 --> 05:03.230
Also, um, you can display things around the current location, like, as, uh, we make here by creating

05:03.230 --> 05:06.830
a circle and around the current location.

05:06.870 --> 05:13.150
Okay, so this is how we can get the current location using Google Maps services.
