WEBVTT

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

00:01.040 --> 00:05.840
We created the Location Repository and Location Repository implementation.

00:05.840 --> 00:10.640
Now let's move to the third step which is the map view model.

00:10.680 --> 00:13.800
Go up inside the constructor.

00:13.840 --> 00:19.640
Pass the location repository private file location repository.

00:19.640 --> 00:22.560
It's of type location repository.

00:22.600 --> 00:30.040
Now let's make use of this location repository in order to get the current location.

00:30.080 --> 00:39.280
Scroll down and here let me create new variables in order to get the current location from the repository.

00:39.520 --> 00:51.760
Val user location equals to location repository dot user location and val has location permission equals

00:51.760 --> 00:56.440
to location repository dot has location permission.

00:56.480 --> 01:01.400
We are fetching the variables from the repository.

01:01.640 --> 01:11.640
Now let's call the other functions from this location repository function start location updates.

01:11.680 --> 01:20.120
This is very simple location repository, dot start location updates and the function stop location

01:20.120 --> 01:20.680
updates.

01:20.680 --> 01:24.240
Or you can override the on cleared.

01:24.240 --> 01:31.680
So on cleared go and set the location repository dot stop location updates.

01:31.720 --> 01:37.400
Okay, now we can handle permission result from activity.

01:37.400 --> 01:46.480
So for example function on permission result if it is granted has location permission dot value equals

01:46.480 --> 01:47.480
to granted.

01:47.640 --> 01:52.600
Then if granted go and start location updates.

01:52.600 --> 01:57.560
You can make it as a type safe or uh like for safety.

01:57.760 --> 02:03.520
So instead of using requires permission you can call on permission result.

02:03.560 --> 02:04.120
Okay.

02:04.360 --> 02:07.040
This is for the A view model.

02:07.080 --> 02:16.080
Now let's move to the user clone map and display the current location as a marker in blue.
