Now let's call this function in map view model.
Open map view model.
Scroll down.
And here we need to create a list that holds the points of the multiple root.
Start with the same logic creating multiple root points.
Equal mutable flow state flow of list of.
Let log and set the initial value to null.
Then set the multi root points equals to multi root points dot as state.
We talked about this pattern in the previous videos and how to create encapsulation and security for
those lists.
We need to create a function that adds markers to the list.
So here add marker to multi root points or multi points root new point.
It's of type lat long val current list equals to multi points value dot or empty to mutable list.
Then set the current list at a new point.
Current list.
Okay, so this function add new markers to multiple points route.
Then we need to create a function that calls the get route for multiple markers function.
So fetch route for multiple markers.
And this function don't need to take anything in parameters because the parameters are passed here in
this function.
So ViewModel scope launch location repository not location repository.
We need to call the directions repository val route equals to directions repository dot get route.
For multiple markers we need to specify the origin, waypoints and destination.
The origin equals to multiple markers.
We need to get the first value.
So multi points dot value we need to get the first value of the multi root value dot first or null.
The second parameter is the Waypoint's multi route points dot value.
We need to remove the first variable because we specify it as a origin.
So here we need to remove n equal to one which refers for the origin.
So here remove origin I want from you guys to focus with me because those are very important step.
And uh and I want from you to learn the logic, how we think, how we, we create professional applications.
Okay.
So here I am removing the origin and removing the destination from the waypoints.
Okay.
Then it is not like this.
Go and create an empty list.
So here empty list.
And we need to specify the destination which is multi root points dot value.
Let's get the last value.
Okay.
So so the idea here is to create and get the origin waypoints and destination.
The origin is the root points.
The first element the destination is the last element.
The waypoints are all the points included in multi-root points except the first and the last element.
This is the logic check.
If root does not equal to null, we need to use multi-root points.
Dot value equals to root, otherwise log root is null.
Okay, in the next video we're going to continue with this function and call it from extended floating
action button.