WEBVTT

00:00.120 --> 00:03.160
Hello developers, and congratulations!

00:03.200 --> 00:05.440
This is an amazing application.

00:05.640 --> 00:17.320
You reviewed many concepts like Firebase retrofit API calls, Firestore, hilt, dependency Injection,

00:17.440 --> 00:27.800
Google Maps and you deal with many complex UI and many complex things in Android development.

00:27.880 --> 00:32.280
Also don't miss the clean architecture you followed.

00:32.320 --> 00:38.400
Okay, so congratulations and let's continue adding new features to our application.

00:38.440 --> 00:49.560
Here we requested the route between the local or the current location and the selected marker on Firebase

00:49.560 --> 00:50.320
Firestore.

00:50.600 --> 00:56.640
Now let us add a new feature for multiple markers.

00:56.640 --> 01:01.920
So we're going to display a route between multiple markers on the map.

01:02.200 --> 01:09.860
So here there is no need for the the starting location, which is the current location.

01:09.860 --> 01:17.900
You can add it by the way, or if we have, for example, a marker in Brazil and a marker in Venezuela.

01:18.180 --> 01:27.900
So you can draw the route between the starting point and through the three markers Bolivia, Brazil

01:27.900 --> 01:28.980
and Venezuela.

01:29.060 --> 01:34.380
So this is the logic that we are going to work on for this purpose.

01:34.380 --> 01:36.420
Let me start from the beginning.

01:36.420 --> 01:39.580
We need to change the directions service.

01:39.580 --> 01:45.900
And here we need to add the additional query which is the way points.

01:46.140 --> 01:56.340
So way points and way points which is of type string equals to null okay.

01:56.540 --> 02:01.140
Then the next step is the directions repository.

02:01.340 --> 02:03.820
Here we created two markers.

02:04.060 --> 02:13.160
The first one to methods get root, which is from the origin, which is the local and the current location

02:13.160 --> 02:14.840
to the selected marker.

02:15.080 --> 02:19.720
And here the route between multiple markers.

02:19.720 --> 02:26.800
But this function needs to return a list of lat long.

02:26.960 --> 02:32.080
The third step is to edit the directions repository implementation.

02:32.080 --> 02:37.080
So here I'm showing you how how to add additional features.

02:37.080 --> 02:43.320
If you think about a new feature and you want to add it to this application, you should pass through

02:43.440 --> 02:45.040
those steps.

02:45.080 --> 02:46.080
Okay guys.

02:46.080 --> 02:49.680
So this is the overwrite suspend function.

02:49.840 --> 02:54.880
We need to return a list of LA long.

02:55.040 --> 02:56.880
And this is good.

02:57.120 --> 02:57.640
Okay.

02:58.000 --> 03:06.000
Now we need to remove this todo and start trying to get the and fetch the waypoints.

03:06.200 --> 03:11.510
Start with try val in the same way as we did before.

03:11.910 --> 03:13.910
The origin value.

03:13.950 --> 03:14.510
The origin.

03:14.510 --> 03:15.190
Variable.

03:15.230 --> 03:15.870
Origin.

03:15.870 --> 03:16.550
Latitude.

03:16.550 --> 03:17.190
Origin.

03:17.190 --> 03:17.950
Longitude.

03:17.950 --> 03:23.990
I'm getting them from here from the passed parameter val destination.

03:23.990 --> 03:32.950
Also in the same way, here we are transforming the origin and destination lat long objects into strings.

03:32.990 --> 03:40.910
Now let me format waypoints for intermediate points val waypoints equals to.

03:41.190 --> 03:51.310
If the size waypoints dot size greater than two, we can draw a destination or a route okay.

03:51.510 --> 03:54.070
So optimize true.

03:54.350 --> 03:57.230
We need to use this format.

03:57.510 --> 04:02.590
This is from the format of the API call.

04:02.750 --> 04:06.630
Waypoints dot sub list one waypoints.

04:06.630 --> 04:12.350
Size minus one dot join string to string.

04:12.550 --> 04:20.010
Set the separator and here set the ID eight dot latitude and longitude.

04:20.010 --> 04:28.330
Here I'm formatting getting all waypoints and setting this request to add it to the API call.

04:28.330 --> 04:36.410
So the waypoint remove the first one which is the origin, and get the separator between the points

04:36.570 --> 04:41.170
and since and get the latitude and longitude.

04:41.530 --> 04:46.770
Then we need to format the response.

04:46.770 --> 04:54.610
So val response equals to the directions service dot get directions.

04:54.770 --> 05:03.330
Set the origin to origin, destination to destination, str waypoints to waypoints and API key to API

05:03.610 --> 05:04.010
key.

05:04.330 --> 05:07.730
Then we need to return the response.

05:07.730 --> 05:12.610
So here we need to return a uh a list of points.

05:12.610 --> 05:17.230
So val points equals to response.

05:19.350 --> 05:26.990
Set the overview polyline dot points and then return poly util.

05:27.070 --> 05:34.630
This is what we used before in order to draw the path between the points and the others.

05:34.630 --> 05:37.870
So map lat lat long.

05:38.150 --> 05:50.510
Set the two parameters the latitude and longitude so it dot latitude and it dot longitude okay this

05:50.510 --> 05:52.150
is the returning type.

05:52.350 --> 05:54.470
Otherwise we need to catch.

05:54.470 --> 06:03.510
So here catch close E exception and set this to return null okay.

06:03.830 --> 06:08.670
So this is the idea behind getting route for multiple markers.

06:08.670 --> 06:14.550
In the next video we're going to call this function and test it on our map.
