Welcome back.
We talked before about the initial camera position.
Now we're going to customize and discuss the camera position.
The camera position in Google Maps determines what part of the map is visible to the user and how it's
displayed.
Zoom level, tilt burning, and so on.
A camera position consists of target the lat long latitude longitude.
The camera is pointing at the zoom level.
Higher is more zoomed in.
Tilt the angle of the camera zero straight down and the bedding.
The orientation zero means north up.
In the previous videos, we created a variable called camera position state.
Here we have it and remember camera position state.
And we set the position to camera position from lat long and we set it to Singapore.
If we run the application without the restrictions that we put, let me remove the restrictions by making
those parameters, command those parameters and run the app.
Let me keep the map type.
Run again.
And here we have Singapore which is the camera position, the initial camera position.
And we talked about the initial camera zoom level that we set it to.
For F we can make it 1514 till 21.
Okay.
Now I want from you to focus with me as I did before.
When longer clicking on the map, the marker is displayed with a title and we can add a blue marker
on the map.
Now I want to use the camera position state in order to zoom in and navigate to the newly created marker.
So if I create a new marker in India with a long click on the map, I need to move the camera to center
it and make it, for example, to the level.
Zoom level 14 and make it as a central marker.
So if I add a new marker here, nothing changed in terms of camera position.
Okay.
Now we're going to move the camera to the newly created one and make an animation to zoom in to 14 uh,
14 f zoom level.
Okay.
In the Google map parameters and on map, click on map long click.
We need to animate camera to new position.
Okay, start with scoop.
I'm using coroutine scoop in order to make camera animations.
So outside the Google map.
Create a new coroutine scoop for camera animations.
Remember coroutine scoop?
Now I'm gonna use this scoop in order to make the animation.
So this is scoop dot launch inside it.
Use the camera position state dot animate.
This function allows us to animate the camera to the newly created position.
If we go to the animate function, we need to pass the update and the duration milliseconds.
In order to do that, we need to create a camera update and pass the camera update and the newly created
value and position camera update.
Factory dot new camera position and here set the camera position from lat long camera position target.
You need to get this camera position that contains the target, zoom and tilt parameters.
If we open the camera position we have lat long which is the target zoom which is a float tilt which
is a is afloat and the burning, which is a float.
So those are the camera position parameters that we need to pass.
So here go to the target, specify the target which is the newly created lat long of the newly created,
uh long long clicked marker.
Zoom level 14 F tilt zero degrees straight down and burning, which is zero F okay, which is north
up.
Let me write this down north up, straight down street level zoom, which is 14 F.
Now we need to specify another parameter which is the duration.
So as I told you in the camera position animate we have two parameters the camera update and the duration
in milliseconds.
Specify the duration which is 1000 which means one second okay one second animation.
Let me run our application and see if there is any change or any error.
If I log click on Australia and you can see that the newly created marker is created on Australia and
the map is navigated to zoom level 14 with a new camera animation, and we set the tilt to zero degrees
and the bearing zero f.
Let me create a new a new long click marker in India.
And here we go.
We are zooming into the street level zoom in India.
Okay.
Let me create another um, like zoom level, make it as eight, which is good in order to make it better.
Also, you can um, specify the same zoom level of your Google map.
So if we scroll up, we can notice that the zoom level was four.
We can make it four.
Not a big deal.
So let me go to China and I love to go to Beijing.
So long click and here we go.
You can control the zoom level.
You can control the birding, the tilt and so on.
Let me show you the tilt.
I'll set it to 30 degrees.
Tilt.
And the north up would be for example, 30 degrees.
Again run.
Make a new marker.
Uh, on Australia.
Long click.
And here we go.
You can see we are tilting the map 30 degrees and the birding set it up to 30 degrees.
You can notice the, uh, the north up and the needle is tilted 30 degrees and not, uh, directly to
the north.
Okay, so this is a full customization of camera position and how we animate the camera to the newly
created markers.