WEBVTT

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

00:00.960 --> 00:03.080
We finished the retrofit section.

00:03.080 --> 00:05.600
Now let's move to the repositories.

00:05.640 --> 00:08.000
Create a new interface.

00:08.240 --> 00:12.200
Name it as directions repository.

00:12.240 --> 00:15.560
We need to fetch the route.

00:15.600 --> 00:20.040
Let's fetch the route between the current position and a marker.

00:20.160 --> 00:22.720
So we need a suspend function.

00:22.720 --> 00:27.000
Get directions or get or get route.

00:27.040 --> 00:30.440
We need an origin which is a left lung.

00:30.600 --> 00:33.360
And we need a destination which is a left lung.

00:33.400 --> 00:38.800
Also this will return a list of left lungs.

00:38.920 --> 00:39.400
Why?

00:39.480 --> 00:51.200
Because, um, in Google Maps, every segment, every leg, every step, every, uh, lag between two

00:51.200 --> 00:56.080
points is defined as a two markers and a straight line.

00:56.480 --> 01:05.880
So we need to collect all those markers in a list of left lungs and display them as a complete route

01:05.880 --> 01:07.120
or a polyline.

01:07.360 --> 01:15.900
So this is the idea behind returning a list of all markers between Origin and destination in order to

01:15.940 --> 01:17.940
display the route.

01:17.980 --> 01:18.540
Okay.

01:18.860 --> 01:27.300
The second function we need to talk about it is fetching the route between multiple markers.

01:27.340 --> 01:30.260
Let's start with suspend function.

01:30.380 --> 01:34.460
Get route for multiple markers.

01:34.460 --> 01:37.700
Here we need to specify the origin.

01:37.740 --> 01:43.460
We need to specify that destination and the way points.

01:43.580 --> 01:47.300
So way points list of lat long.

01:47.300 --> 01:51.180
And the destination is a single marker.

01:51.300 --> 01:54.220
Why we use the waypoints as a list.

01:54.260 --> 01:56.140
The origin is a marker.

01:56.180 --> 01:58.500
The destination is a marker.

01:58.500 --> 02:06.780
And between those two points we have the waypoints, which is a list of lat long.

02:07.020 --> 02:15.140
This list contains all the markers between the origin and destination that we want to display the route

02:15.180 --> 02:18.060
between them, including the waypoints.

02:18.060 --> 02:22.940
So we have the origin starting from this marker.

02:23.140 --> 02:25.900
Then we move through the waypoints.

02:26.030 --> 02:33.350
maybe one, maybe 50 markers and so on until reaching the destination.

02:33.350 --> 02:38.830
By the way, there is a limit which is 24 markers in Google Maps.

02:39.070 --> 02:47.590
This is due to the complex algorithms that we need to execute during fetching the route, and the fastest

02:47.590 --> 02:53.190
route between the destination origin and including the way points.

02:53.190 --> 02:59.070
So this is a big, um, big query and big request.

02:59.110 --> 03:07.070
Even Google Maps will will restrict you from making more than 24 markers, because there are a lot of

03:07.070 --> 03:11.510
algorithms will work in order to get your response.

03:11.550 --> 03:16.990
Okay, so the idea here is the origin destination.

03:16.990 --> 03:20.750
And through this route we have waypoints.

03:20.750 --> 03:29.590
We need to fetch the the origin, the markers included in the waypoints and then reaching the destination.

03:29.790 --> 03:30.230
Okay.

03:30.270 --> 03:37.430
So we have two main functions in our application we need to work on.
