Hi.
I'm Mano Marks.
I'm coming to you from the Googleplex in Mountain View,
California.
I'm on the Maps Developer Relations Team, and this is a
new Google Maps shortcut on using tile layers in the
Google Maps SDK for iOS.
So what is a tile layer?
A tile layer is you providing to the map a layer of raster
images in a pre-defined URL scheme that you give to us,
and then we render those tiles on top of our map in the SDK.
So let's take a look at a demo for you.
This demo actually comes with the Google Maps SDK.
So if you download the SDK, you'll see that it's in there.
You add your own key, and then you'll be able to run a
variety of different samples.
This one is a tile layer that we generated for the 2010, I
believe it was, Google I/O showing the Moscone Center
different floors.
So you'll see here we have a little controller which I can
switch between, and we'll see different maps.
And you can even, if you watch closely enough, see that you
can see some of the tile boundaries until I've loaded
it enough times that that doesn't show up.
So what I'd like to do is show you how to actually put this
code on your own application.
So let's take a look at the sample code here.
I'm not going to go through all the constructing a map
stuff because we've done that many times.
But let's just take a look at this ChangeSwitcher here.
So you'll see here there's a GMSTileURLConstructor urls.
Basically it's a quick method to show how to construct a
tile URL based on your own tiles.
So you see here you're passing it at an x, a y, and a zoom.
And these are the dimensions of your tiles.
So the base URL here is here.
We're just showing you a URL that we actually have at
Google, tiles, and then you'll see here this is a
stringWithFormat there.
It takes floor, zoom, x, and y.
So floor is the floor that you've selected.
So you can see you can construct your own URL here,
not just with the x, y, and zoom.
And then you create a new GMSURLTileLayer and construct
it with a tileLayerWithURL Constructor:urls.
And then you set the map on that to your map view.
So it's pretty easy to do once you've constructed your own
URL scheme.
And you can use the same URL scheme, the same formats, as
you would use for an Android or web application that would
also be using a tile layer or a tile overlay.
We've also added the ability to do customization for this.
So you can actually generate these tiles from URLs within
your application or actually generate custom
images on the fly.
So let's take a look here.
I'm just going to show you some of the
basic code for that.
Here we're subclassing GMSSyncTileLayer.
So that's the header.
And then this is the implementation.
This is just code that's in the documentation itself.
So you see here in the implementation, we are
changing tile for x, y, and zoom.
And here, for every odd tile, we're rendering an image and
pulling up an image from the resources named australia.
So basically, it's just rendering a map of Australia
every other tile and then not rendering one otherwise.
So you can see here, there's the constant
GMSTileLayerNoTile.
So let's take a look at the demo again here, now that
you've seen the code.
So you see here, as we're selecting the floor, it's
passing, it's changing the URL for the layer, setting the
original layer to nil, and then rendering new tiles on
top of the map based on that URL scheme.
So that's it.
It's actually a pretty simple process.
And this allows you to generate your own imagery and
map tiles and then render them on top of our map.
So that's all for this week.
Thanks very much, and happy mapping.