Welcome back.
In the previous video we said that items should be of type cluster item.
So we need to create a list of any type that extends from cluster item.
So we're going to create in this video a new Kotlin class named as my cluster item that extends from
cluster item.
And we're going to create a list from this class in order to pass it to the items parameter of clustering.
Composable.
Let's start with data class.
It's a data class of cluster items.
And here we need to specify the parameters of this class.
Start with val item position.
It's of type lat long val item title.
It's of type string val item snippet.
It's of type string val item z index it's of type float Alt+.
Enter to import lat long and this will extend from cluster right.
This is our custom data class.
My cluster item that implements the cluster item interface from Google Maps Android SDK utility library.
This class serves as a wrapper for individual items that will be displayed as markers on the map when
zoomed in, grouped into clusters when zoom out, so this data class will act as a wrapper for individual
items.
When zooming in, it will display the markers.
When zooming out, it will display the group or the cluster.
The item position property is of type lat long.
The geographical location of the item required by cluster item interface to determine where to place
the marker.
Item title the title that appears when the marker is clicked.
Used for the markers.
Info window.
Item snippet additional text that appears below the title in the info window provides more context about
the marker and Val.
Oops.
Here there is an error val item Z-index controls the draw Order of markers.
Which markers appear above others?
Higher values will appear above markers with lower values.
Okay, this is our data class.
This data class extends from interface called cluster item.
We need to implement the members.
So here implement members click okay.
And here we have four methods implemented from the cluster item.
We need to modify them.
So here equals to item position.
Get title equals to the title.
Get snippet equals to the snippet and get the index the item's index also here item snippet and item
snippet item title okay, this is our data class that serves as a template for every item in the cluster.
So when the user zooms in, the markers are being displayed.
When the user zooms out, it will collapse and be grouped into clusters.
This is the main purpose behind creating this class.