With the basic app you've just built,
you can configure the initial state of the map in a number of ways.
For documentation on all of the ways you can configure it, using XML attributes,
look in the instructor notes below.
But for now we'll configure a few attributes to show
something interesting.
So here's the layout that you had just created with your fragment
containing the maps fragment.
And this gave you the default Google maps that you've been using throughout.
But what we're going to do is we're going to change this.
So we're going to take a look at New York City with a flyover type view.
So first of all, there's going to be a number of attributes on the fragment
that we're going to need to set.
And we're going to do these using the Maps namespace.
So we need to tell the XML about the Maps namespace first.
So I'm going to do that up here.
And you see, we have XML namespace tool equals this.
We're going to create a new XML namespace for our map.
And here are the details for the XML namespace for map.
As you can see, xmlns:map is equal to
http://schemas.android.com/apk/res-au- to/.
So this will give us the map attributes that we can now add to our fragment.
Map attributes will consist of things such as the latitude and
the longitude of what you want to look at.
So the latitude and
longitude of the area in New York City we're going to look at a la now.
Here you can see, I've added the map camera target latitude and
map camera target longitude.
Don't worry about the red underlines on them at the moment.
Now, when you're looking at a map,
you actually look at a map through a virtual camera.
So you tell the camera the target latitude and
longitude that it's going to look at.
So the latitude of downtown New York City is 40.7484 and
the longitude is negative 73.9857.
But what this is going to do is, if you remember when you first run the map,
you had a view from high in orbit looking down on the Earth.
And this will do that, but it will be looking down on New York City.
But all it's going to do is shift the camera.
>From being high in orbit looking down on
the equator to being high in orbit looking down on New York City.
So we also want to move the camera so we zoom down onto New York City.
And we'll change a couple of things.
I'm going to add them and then talk through them one by one.
So these are the three attributes that I've added.
The first is the Camera-Bearing.
The Camera-Bearing is the direction that the camera is looking at,
with zero degrees being looking north, 180 degrees being looking south.
So as a result, you can see I'm looking at 112.5 degrees, so
I'm kind of looking east with my camera bearing.
Next is going to be the camera tilt, so if you can imagine the camera when it's
looking straight down, it's going to be tilted at 90 degrees.
But if I can change that to 65 degrees,
then the camera is going to be appearing somewhat at an angle looking down, so
we have a nice 3-D isometric view of the world beneath us.
And then finally is the Camera ZOOM.
The larger the number, the closer you are to the surface of the Earth.
So if you can imagine a Camera ZOOM 0, that's what we've had all along,
where the camera is way up.
Looking down on the Earth.
But with a Camera ZOOM 17, I'm going down really close to the Earth.
And as you'll see, because I've got a camera tilt of 65 degrees,
I'm getting a 3D view of the skyscrapers in New York City.
And with the Camera ZOOM being 17,
I'm actually lower than the level of some of these skyscrapers.
So, let's run the application and see what it looks like.
So, now here we see the application running on my tablet.
It gives us a view of downtown New York, and I can actually scroll around and
see the city in three dimensions.
So I can see some of the skyscrapers that are cylindrical in shape.
And as we had an earlier on,
we were actually looking the base of the Empire State Building, and here you can
see the Empire State Building rising out of the view of the camera.
Because the camera is actually lower than the height of the building.
And as I zoom around New York City and I pan around, we can take a look at some
of the interesting features in some of the buildings.
For example, here is the United Nations headquarters, overlooking the river.
Here are things like some of the islands in the river itself, and
we can see the skyscrapers on them.
Sometimes, it takes a little while for them to show up.
So you've effectively gotten all of this for free,
you didn't need to set up anything to get the 3D views or anything like that.
Just basically by the fact that you tilted the camera and
were close enough into the earth, to be able to see the 3D views.
If I were to zoom out you'll see,
I'm just going to see now a pan-view of New York City without the 3D.
As I zoom out, you can see we were facing towards the East,
looking out over Long Island.
When I zoom in over the city again, once I get close enough we'll start seeing
the buildings and the skyscrapers popping up.
And there they are.
Pretty simple,
just all of this was done just by setting attributes on the map fragment.
Pretty cool, right?