WEBVTT

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

00:01.160 --> 00:05.680
We finished the geocode address and we talked about the geocoder.

00:05.840 --> 00:12.320
Now let's move up and outside the box that contains the Google map.

00:12.440 --> 00:22.280
Here I'm going to create the variables that we're going to use in our geocoding process for our search

00:22.320 --> 00:29.880
query, which is a variable that holds a string for the search query.

00:29.920 --> 00:32.840
Mutable state of empty string.

00:32.920 --> 00:35.840
VAR location by.

00:36.040 --> 00:40.280
Remember mutable state of null.

00:40.400 --> 00:44.960
Initially null, but it's of type lat long.

00:45.160 --> 00:48.520
Then var address by.

00:48.920 --> 00:52.760
Remember search or tap on map.

00:52.760 --> 01:03.190
I need to add this question mark and correct the location name var coroutine Scoop equals to remember

01:03.190 --> 01:04.870
coroutine scope.

01:04.910 --> 01:14.670
In Kotlin and Jetpack Compose, this coroutine scope equals to remember coroutine scope is used to create

01:14.950 --> 01:21.710
a remember a coroutine scope that is tied to the lifecycle of a composable function.

01:21.910 --> 01:28.310
The coroutine scope defines the lifecycle of coroutines launched inside it.

01:28.510 --> 01:34.430
If the scope is canceled, all its child coroutines are automatically canceled.

01:34.590 --> 01:44.350
Useful for managing background tasks like API calls, animations, or other async operations.

01:44.350 --> 01:46.390
Remember coroutine scope.

01:46.670 --> 01:55.270
This function creates and remembers a coroutine scope tied to the composition lifecycle.

01:55.510 --> 02:01.510
The scope will automatically be canceled when the composable leaves the composition.

02:01.660 --> 02:09.460
Example when the composable is removed from the UI, unlike launched effect, which runs a coroutine

02:09.460 --> 02:10.100
once.

02:10.140 --> 02:19.220
Remember, coroutine scope allows you to launch coroutines in response to UI events like button clicks.

02:19.380 --> 02:24.780
When we need to use it, you need to manually launch coroutines.

02:24.780 --> 02:31.340
You need to use remember coroutine scope in response to other interactions like button clicks.

02:31.500 --> 02:40.180
And in this case, we're going to use it in order to get the in background, uh, the location for the

02:40.180 --> 02:40.980
geocoding.

02:41.020 --> 02:41.460
Okay.

02:41.580 --> 02:46.540
Then inside the Google map scope, scroll down.

02:46.540 --> 02:51.540
And here we need to make a geocoding part.

02:51.860 --> 02:57.180
So geocoding start with location variable.

02:58.500 --> 03:07.050
Let let location Lat long, which is the parameter for the lambda expression marker.

03:07.290 --> 03:16.170
Set the state marker state title equals to the address snippet and set the longitude dot longitude.

03:16.210 --> 03:17.850
Okay, this is the marker.

03:17.890 --> 03:27.770
This code is used to display a marker on a map if a location location lat long and is available.

03:28.130 --> 03:34.250
So here location which is of type lat long is a nullable object.

03:34.250 --> 03:39.970
If we go back to here scroll down to geocoding.

03:40.130 --> 03:49.730
You notice that the location variable is of type mutable state of lat long and the initial state of

03:49.730 --> 03:50.850
it is null.

03:51.050 --> 04:01.730
So here I am checking if location is not null, then a coroutine scope function will be executed using

04:01.770 --> 04:03.550
the let keyword.

04:03.870 --> 04:09.150
So let here the question mark dot let and the lambda expression.

04:09.150 --> 04:20.390
Here is a coroutine scope function that executes the lambda block only if location is not null inside

04:20.390 --> 04:21.950
the block location.

04:21.950 --> 04:27.590
Let long refers to the non-null location value.

04:27.750 --> 04:38.910
Okay, so here if location is not null, execute or execute the loop or the lambda function.

04:38.950 --> 04:39.430
Okay.

04:39.630 --> 04:47.990
Why we use let safely handles null values because we initialized the location as null and location could

04:47.990 --> 04:48.670
be null.

04:48.950 --> 04:55.430
Uh provides a clean way to transform or use the value if it exists.

04:55.550 --> 04:59.950
Then we created a marker, which is a compose map marker.

05:00.190 --> 05:05.180
It takes several parameters the state, making a state the location.

05:05.180 --> 05:08.660
Lat Lon controls the marker's position and visibility.

05:08.940 --> 05:12.500
And here the title, which is the address type.

05:12.540 --> 05:19.900
Typically a string snippet displays additional information as we learned before.

05:20.100 --> 05:26.340
Okay, so this is the part of the location checking the location variable.

05:26.340 --> 05:32.740
The third part is to create the geocoding user interface.

05:33.060 --> 05:38.900
So outside the map scoop scroll down.

05:38.940 --> 05:44.540
Here we have this the and this parentheses the end of the scoop of the map.

05:44.660 --> 05:52.220
And now we can create the user user interface overlay for geocoding.

05:52.260 --> 05:56.460
In the next video we're going to continue with the geocoding user interface.

05:56.700 --> 05:59.500
And it's very simple user interface.

05:59.540 --> 06:03.540
We need to create a text field a button and a text.
