Learned about the camera position, the initial zoom level, the Google map types, and other things.
Now let's move to learn about markers.
Adding markers to a Google map in Jetpack Compose allows you to highlight specific location.
If I want to make a new pin here, place a new pin in Singapore.
All I need is to go to that Google map and here inside the scope of it, create a new marker marker
and import the class of the marker.
This is a composable function control and left mouse to open the the definition and the composable function
of marker.
We have different parameters, different attributes like the state.
And this is by the way, the most important attribute.
The marker state tracks the markers position and visibility.
It's of type marker state marker, state control and left click.
We have one parameter is the position, which is lat long.
You remember the lat long the latitude and longitude variable.
So inside the marker we can define a state.
And inside the state we define.
The position of the marker can be updated programmatically and the marker composable.
The actual marker displayed on the on the map requires a marker state, accepts optional title, snippet
and click handlers.
Uh, the others uh, and the other uh like attributes are optional.
Okay.
But the most important thing is the marker state, which handles and the tracks the markers position
and visibility.
For example, let me start by adding the state attribute and here use the marker new marker state.
Alt plus enter to import it and set the position to Singapore.
Singapore is a variable that we defined before.
It's of type lat long.
Scroll up lat long.
This is the Singapore variable.
Okay.
This is the marker.
We put it inside the Singapore.
Okay.
Let me run.
And you can notice this is our marker.
Okay.
If we zoom out you can notice that this is our marker in Singapore.
Now let's customize this marker.
We can add for example title and snippet.
Marker Singapore and snippet is a small title a small description under the title.
Let me run again.
Here we go.
If I click on the marker Singapore marker in the Singapore.
Okay.
Did you notice that the snippet here.
Okay.
So this is our marker.
If we go back to the marker declaration we have anchor alpha draggable flat icon and others.
Okay.
Let me show you for example alpha.
Set alpha equals to 0.5 f.
Run.
It controls the visibility of the marker and the transparency.
You can notice that the color of this marker is 50% off.
Okay we have anchor draggable flat icon.
We can customize the icon.
So for example if I need to switch this ordinary icon and replace it by another one another image.
Let me create the icon here val.
Custom icon equals to bitmap description factory script or factory default marker and set the bitmap
descriptor factory dot.
Read and set the icon to custom icon run.
Again, I am getting the default icon default marker and set it to Azure.
I can set it to other colors like magenta.
And here we go.