WEBVTT

00:00.120 --> 00:00.960
Welcome back.

00:01.320 --> 00:09.640
When the user clicks on the map, there is a new marker created but not saved to the firestore.

00:09.760 --> 00:17.240
When the user clicks on request right, this marker will be uploaded to the firestore and saved.

00:17.360 --> 00:28.200
So if we run the application again, the marker in Bolivia is being saved to the firestore and received

00:28.360 --> 00:30.760
during the application launch.

00:30.880 --> 00:39.560
Again, if I want to draw the route between the current location and the selected location, I need

00:39.560 --> 00:44.760
to select the marker and click Draw Route.

00:44.800 --> 00:54.680
But there is this is a problem here because there is a no route between the selected marker from Firestore

00:54.680 --> 00:56.400
and my current location.

00:56.640 --> 01:03.670
If I drop a new marker here in Paraguay, select it And click draw root.

01:03.670 --> 01:06.510
The root is fetched successfully.

01:06.510 --> 01:12.830
So the problem is when the user clicks on the firestore markers.

01:13.070 --> 01:15.390
Let me go back to the Uber clone.

01:15.390 --> 01:24.990
And here we need to set the selected marker where variable to the selected marker from Firestore.

01:25.150 --> 01:29.790
So I am teaching you how to test your applications.

01:29.950 --> 01:36.350
Here we have an error when clicking on any marker of Firestore markers.

01:36.390 --> 01:38.350
There is no root here.

01:38.830 --> 01:47.390
We have successfully drawing route between any marker on the map that it is not saved or fetched to

01:47.430 --> 01:49.110
Firebase Firestore.

01:49.350 --> 01:51.390
So how to solve it.

01:51.430 --> 01:55.710
We need to check the markers of Firestore.

01:55.830 --> 01:58.790
Go back to Uber Clone map.

01:59.070 --> 02:03.230
And here the markers list.

02:03.430 --> 02:08.590
Let me change it from markers to markers in Firestore.

02:08.950 --> 02:10.790
Scroll up here.

02:10.950 --> 02:14.430
Markers in Firestore.

02:14.630 --> 02:18.390
Scroll down markers in Firestore.

02:18.430 --> 02:26.710
For each marker go and create a marker and set the title to the marker dot title.

02:26.710 --> 02:32.230
Or you can simply make it as Firestore marker.

02:32.350 --> 02:36.710
Set the snippet to marker coordinates and set on.

02:36.710 --> 02:38.950
Click ViewModel dot.

02:38.990 --> 02:48.030
Set selected location to the selected marker okay to Latlong and here return false.

02:48.070 --> 02:51.710
Now I want to show you something.

02:51.910 --> 02:53.070
Let me run.

02:53.070 --> 02:58.870
If I select any marker, we get Firestore marker.

02:59.070 --> 03:04.340
You can change it to Marker title.

03:04.340 --> 03:08.940
So for example marker dot title okay.

03:09.180 --> 03:14.700
So here you can customize the marker as you want.

03:14.740 --> 03:16.140
Let me click Italy.

03:16.260 --> 03:21.100
Nothing displayed because there is an error in the marker title.

03:21.100 --> 03:27.460
If we go back here to Italy we have only latitude and longitude.

03:27.460 --> 03:33.140
If I need to get the title of the document, it's very simple.

03:33.140 --> 03:34.500
So here is a trick.

03:34.820 --> 03:39.540
The ID of the document represent it or its name.

03:39.540 --> 03:46.060
So here let me change the marker dot title to marker.id run again.

03:46.060 --> 03:51.020
Click on Italy and you get Italy London, Paris.

03:51.020 --> 03:59.460
And here we in Bolivia we have the destination because the name of the marker is set it to a destination

03:59.460 --> 04:01.660
with lat and long.

04:01.820 --> 04:02.340
Okay.

04:02.580 --> 04:07.050
So here you can customize the marker as you want.

04:07.090 --> 04:18.530
Also, you can drop a marker here and when saving to Firestore you can request from the user what name

04:18.610 --> 04:25.050
you should or he should name it for this newly created marker.

04:25.090 --> 04:28.730
Let's test our algorithm and logic.

04:28.730 --> 04:38.770
So click on this saved location and retrieved marker from Firebase Firestore and request the route.

04:38.890 --> 04:41.490
If I request the route.

04:41.490 --> 04:46.810
So there is no route displayed between the current position and the selected marker.

04:47.010 --> 04:50.970
Even though let me test the selected marker.

04:50.970 --> 05:00.650
So here inside the marker in Firestore when I click on any marker, I added this Logcat tag and the

05:00.650 --> 05:08.080
selected marker to let log if I run the application again and select any marker.

05:08.240 --> 05:15.400
Go to Filter Tag and here the current position and the selected lat long is displayed correctly.

05:15.640 --> 05:17.480
Again let me check this.

05:17.640 --> 05:23.120
If I click Bolivia that the lat long is displayed correctly.

05:23.120 --> 05:26.080
So the the problem is in the algorithm.

05:26.200 --> 05:33.040
Let me scroll down here inside the expandable fab in Uber clone map on draw route.

05:33.080 --> 05:34.280
Here we have.

05:34.280 --> 05:42.640
If marker position is not null and this is not the case, we have the marker position or the marker

05:42.640 --> 05:45.560
retrieved from Firestore.

05:45.560 --> 05:53.240
So in this case we can change it to selected location does not equal to null.

05:53.400 --> 05:56.600
Let me run again select Bolivia.

05:56.760 --> 06:01.480
Click Draw Route and to check the look at here.

06:01.600 --> 06:07.560
The selected is not null but the application crashes again.

06:07.600 --> 06:09.400
Selected location.

06:09.440 --> 06:14.200
Here the ViewModel dot fetch route from current position to marker.

06:14.400 --> 06:16.800
We don't need the marker position.

06:16.840 --> 06:20.440
We need the selected location.

06:20.480 --> 06:23.640
Dot two exclamation marks.

06:23.680 --> 06:29.800
Run again because we are testing the selected location and not the marker position.

06:29.840 --> 06:33.960
The marker position is any marker drawn by the user.

06:33.960 --> 06:42.000
When the when he clicks on the map, the selected marker is the marker that it is saved and fetched

06:42.000 --> 06:43.760
from Firebase Firestore.

06:43.920 --> 06:44.920
Draw route.

06:44.960 --> 06:46.400
And here we go.

06:46.600 --> 06:48.200
Congratulations guys.

06:48.400 --> 06:50.720
Now we can save markers.

06:50.880 --> 06:52.920
We upload rides.

06:53.040 --> 06:56.160
We upload request write request.

06:56.160 --> 07:04.800
And the user and the driver can fetch the route between the current position and the destination or

07:04.840 --> 07:06.880
the requested ride.
