Welcome back.
Let's continue with the places API integration.
Start by var query or places query by.
Remember mutable state of empty string.
The second variable is called predictions.
So predictions by.
Remember it's of type mutable state of empty.
And we need to specify a new type of variables here which is autocomplete prediction.
So list of autocomplete prediction.
This line of code in Jetpack Compose used to manage a list of autocomplete predictions.
For example, search suggestions from the Google Places API in a way that automatically updates the
UI when the data changes.
Here we are declaring a variable called predictions that suggests locations as the user types and by
remember, remember retains the value across composable recomposition keeps state alive when the UI
refreshes.
Mutable state of makes the variable observable.
Changes to predictions will automatically trigger a decomposition of the UI and initial value.
Empty list starts with an empty list.
List of autocomplete prediction A list of autocomplete predictions, for example place names addresses
returned by the places API.
Okay, so this is the main purpose behind creating this type of variables.
The third variable var selected place by.
Remember mutable type mutable state of.
Start with null.
And here we can create a new type of variables called place.
So this type is imported from the places API.
You can see if I hover the mouse that places variable.
Okay.
So we import it from API modal place.
Now let's move to the Google map scoop.
So here before geocoding we can use our places API.
Let's start by selecting the place.lat.
And here the variable is place.
The parameter is a place.
Then we need to make a place.lat long.
From lat long we can get.
If it is not null then go and create a marker or we can directly use this marker state okay state marker
state and the position is place.lat long.
Or we can directly use lat long.
The name is placed dot name and the snippet is place dot address.
So this is our places API implementation in Google Map.
Now click on this in order to get the scope of Google Map.
And outside this box scroll down until here.
Here we need to create or outside the box.
We need to create inside the box.
Sorry.
And under the Google map scope here places api ui overlay.
Start with colon inside this colon.
We need to create a text field and lazy colon.
So let's start with modifier dot padding 16 dp.
And inside the scope of this colon start with a text field.
Setting the value equals.
To query on value change we need to set places query.
Don't miss it.
The on value change we need to start with the new query lambda expression, set the search query to
it.
If new query dot length greater than two, then what we need to do go and execute a new val request
equals to find autocomplete predictions request dot builder dot set query pass in new query and then
use the build function.
What we've done here.
This code constructs a request object to fetch autocomplete predictions.
Search suggestions from the Google Places API.
The purpose is used to search for places as the user types.
For example, if the user types uh p a r, so it will give him Paris, France or Park Avenue in New
York.
Okay, so this is the prediction.
This is how we get the data from the user and predicts the autocomplete.
And the text returns a list of autocomplete prediction objects.
Place suggestions.
Okay, so find autocomplete prediction request.
Creates a builder to configure the request.
Set the query sets the search query, for example text from a text field.
In this case and build function finalizes and constructs the immutable request object.
Okay.
So again guys, if the user types p a r, the app will give him two suggestions.
Even the either Park Avenue in New York or Paris in France.
Okay, then we need to get and induce this, uh, this request in order to find the autocomplete prediction
request.