WEBVTT

00:00.080 --> 00:03.360
Now let's call this function in map view model.

00:03.400 --> 00:04.640
Open map view model.

00:04.840 --> 00:05.880
Scroll down.

00:05.880 --> 00:12.320
And here we need to create a list that holds the points of the multiple root.

00:12.360 --> 00:17.840
Start with the same logic creating multiple root points.

00:17.880 --> 00:22.560
Equal mutable flow state flow of list of.

00:22.600 --> 00:25.760
Let log and set the initial value to null.

00:26.000 --> 00:33.600
Then set the multi root points equals to multi root points dot as state.

00:33.640 --> 00:41.200
We talked about this pattern in the previous videos and how to create encapsulation and security for

00:41.200 --> 00:42.440
those lists.

00:42.480 --> 00:49.400
We need to create a function that adds markers to the list.

00:49.400 --> 00:58.120
So here add marker to multi root points or multi points root new point.

00:58.160 --> 01:10.000
It's of type lat long val current list equals to multi points value dot or empty to mutable list.

01:10.040 --> 01:13.520
Then set the current list at a new point.

01:13.520 --> 01:15.000
Current list.

01:15.040 --> 01:21.320
Okay, so this function add new markers to multiple points route.

01:21.360 --> 01:29.080
Then we need to create a function that calls the get route for multiple markers function.

01:29.080 --> 01:32.400
So fetch route for multiple markers.

01:32.520 --> 01:41.640
And this function don't need to take anything in parameters because the parameters are passed here in

01:41.760 --> 01:43.200
this function.

01:43.200 --> 01:48.760
So ViewModel scope launch location repository not location repository.

01:48.800 --> 02:00.400
We need to call the directions repository val route equals to directions repository dot get route.

02:00.400 --> 02:08.160
For multiple markers we need to specify the origin, waypoints and destination.

02:08.200 --> 02:12.400
The origin equals to multiple markers.

02:12.670 --> 02:15.790
We need to get the first value.

02:15.790 --> 02:25.870
So multi points dot value we need to get the first value of the multi root value dot first or null.

02:26.070 --> 02:32.790
The second parameter is the Waypoint's multi route points dot value.

02:32.990 --> 02:41.550
We need to remove the first variable because we specify it as a origin.

02:41.750 --> 02:48.750
So here we need to remove n equal to one which refers for the origin.

02:48.990 --> 02:57.630
So here remove origin I want from you guys to focus with me because those are very important step.

02:57.750 --> 03:06.670
And uh and I want from you to learn the logic, how we think, how we, we create professional applications.

03:06.710 --> 03:07.230
Okay.

03:07.270 --> 03:12.390
So here I am removing the origin and removing the destination from the waypoints.

03:12.430 --> 03:12.950
Okay.

03:13.190 --> 03:15.710
Then it is not like this.

03:15.750 --> 03:18.590
Go and create an empty list.

03:18.630 --> 03:20.910
So here empty list.

03:20.910 --> 03:27.910
And we need to specify the destination which is multi root points dot value.

03:27.950 --> 03:30.870
Let's get the last value.

03:30.910 --> 03:31.470
Okay.

03:31.670 --> 03:39.230
So so the idea here is to create and get the origin waypoints and destination.

03:39.270 --> 03:41.790
The origin is the root points.

03:41.790 --> 03:46.430
The first element the destination is the last element.

03:46.470 --> 03:55.630
The waypoints are all the points included in multi-root points except the first and the last element.

03:55.870 --> 03:58.630
This is the logic check.

03:58.630 --> 04:04.710
If root does not equal to null, we need to use multi-root points.

04:04.710 --> 04:10.950
Dot value equals to root, otherwise log root is null.

04:10.990 --> 04:19.550
Okay, in the next video we're going to continue with this function and call it from extended floating

04:19.590 --> 04:20.510
action button.
