Welcome back.
In this video we're going to learn about ground overlay.
A ground overlay is an image that's fixed to a map at a specific geographic coordinates.
Unlike markers that appear at points, ground overlays cover an area of the map.
They are useful for displaying historical maps showing planned construction sites, adding custom image
layers, and visualizing heatmaps or special zones.
We can use the map overlays positioned using latitude and longitude coordinates can be rotated and tilted.
Supports transparency and sized using either dimensions with height or bounds.
South west West or north east corners.
Okay, to create a map overlay, we need an image for the position.
So I downloaded this image for New York City and Manhattan.
And I'm gonna use this image, which is historical, for displaying it as an overlay for my map.
Okay.
So copy it, name it as NYC, New York City.
Copy it, place it inside the drawable folder, click okay.
And here we go.
This is our image I need to place it exactly over New York City which is here.
Okay.
Let's start with the Manhattan coordinates.
I need to create a bound not a marker.
Marker is used for points while while overlays start as a map area.
Okay.
So you use bounds for making a bound for the area using.
When using the map overlay and when using markers, you should specify a point.
Okay, let me start with val.
Manhattan bounds equals to lat long bounds.
Lat.
Long.
This is the lat long for the south west corner.
And this is the lat long for the north east corner.
Then inside the Google map scope I need to create a ground overlay, which is a composable ground overlay
and the specify the position.
Use this, use this and import this.
Composable, not the class.
Please pay attention.
This is a composable.
This is a class.
And you can notice that we we have a position image anchor bearing clickable and those parameters for
the ground overlay.
And I'll use it.
So please pay attention to the things that you import.
Set the position to Manhattan bounds.
The image would be from Bitmap Descriptor Factory.
Don't worry I'm going to explain everything from from a resource are that drawable dot Manhattan or
NYC.
Then set the transparency to 0.3 f, which is 30% transparency.
Okay, let me open the ground overlay composable by Ctrl and left click.
And this is the Google map.
Composable.
We have many parameters.
Let's start with the position.
The position.
This defines the position and size of the overlay.
There are two ways to specify using the latlong bounds or using a Latlong, which is the anchor point
along with the width and height in meters, and Latlong bounds south west and north east corners to
define the area using the ground overlay position, so Ctrl and left click, you can uh, open the ground
overlay position, having the latlong bounds, the location width and height, and this is used for
creating the position of the ground overlay the image, which is a bitmap descriptor that specifies
the image to be used for the overlay.
You can create it using Bitmap Descriptor Factory.
The anchor parameter used along with a width and height in meters to make the offset and make it like
offsetting from the main and the central point.
The bearing the burning, which is an optional parameter, which is the rotation of the overlay in degrees
clockwise from north and the default is zero.
Clickable.
We can specify it, which is an optional parameter.
Also boolean indicating if the overlay is clickable and the default is false.
Transparency.
A float between zero opaque and one transparent for the transparency level.
The default is zero.
We specified it as.
We specify it as 0.3, which is 30% Transparent visible boolean to control the visibility.
Default is true.
Z index the z index of the overlay which determines the stacking order.
Higher values are above lower ones.
Unclick a callback when the overlay is clicked.
Only called if clickable is true.
This is the main parameters of the ground overlay.
Here we have an error required.
Ground overlay position found lat long bounds.
Let me explain about the ground overlay position here.
I'm gonna show you how to convert the ground overlay position to ground overlay.
Okay.
So I want from you to focus with me.
And please pay attention because I am going to show you how to deal with different upgrades and how
to face upgrades of Google Composables and documentations and SDK because Android is keep updating.