Google maps API v3

2,367 views
Skip to first unread message

Gmail

unread,
Jun 2, 2010, 10:29:27 AM6/2/10
to mapt...@googlegroups.com
Does map tiler support v3 of the google maps API?

Shaun Bentzen

Klokan Petr Přidal

unread,
Jun 2, 2010, 11:42:52 AM6/2/10
to mapt...@googlegroups.com
Shaun,

MapTiler generates example mashup only in Google Maps V2, but the
tiles are fully usable in V3, OpenLayers and other viewers.

Here is an example of Google Maps V3 mashup with MapTiler tiles:

http://www.maptiler.org/example-usgs-drg-grand-canyon-gtiff/v3.html

Feel free to copy&paste the JavaScript source code and use it with
your own tiles - the code is really straight forward:

<script>
var maptiler = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
return zoom + "/" + coord.x + "/" + (Math.pow(2,zoom)-coord.y-1) + ".png";
},
tileSize: new google.maps.Size(256, 256),
isPng: true
});

var map;
function initialize() {
map = new google.maps.Map(document.getElementById("map_canvas"));
map.setCenter(new google.maps.LatLng(36.07, -112.19));
map.setZoom(11);
map.setMapTypeId('satellite');
map.overlayMapTypes.insertAt(0, maptiler);
}
</script>

Best,

Klokan

On Wed, Jun 2, 2010 at 4:29 PM, Gmail <sben...@gmail.com> wrote:
> Does map tiler support v3 of the google maps API?
>
> Shaun Bentzen
>

> --
> You received this message because you are subscribed to the Google Groups "MapTiler User Group" group.
> To post to this group, send email to mapt...@googlegroups.com.
> To unsubscribe from this group, send email to maptiler+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/maptiler?hl=en.
>
>

--
http://blog.klokan.cz/
http://www.maptiler.org/
http://www.oldmapsonline.org/

SnowBeard

unread,
Jun 10, 2010, 3:01:39 PM6/10/10
to MapTiler User Group
Hi Klokan

Firstly, massive thanks for producing Maptiler - it rocks!
I've created a mash-up for V3 using your Grand Canyon example code
snippet, and with the help of my 2 lovely assistants Miss Cut & Miss
Paste; everything looks ok and it appears to work well, but I've
noticed in my site stats that I'm getting a lot of 404 errors for .png
tiles which probably lie outside the bounds of my custom map. Have you
experienced anything similar with V3?
I'm guessing it's because the getTileUrl function doesn't have any way
to set the map bounds or any /none.png redirect like Maptiler does as
standard for V2; and I can't find any reference for any setBounds or
similar in the official Google Maps V3 API tutorial/reference.
I can handle the problem using .htaccess redirects of course, but
there must be an easier and more elegant way. Probably using an 'if'
function in the javascript, but I'm just a beginner with js and I
haven't worked that out yet. Any ideas greatly appreciated.
Here's the url of a page displaying the first of my V3 examples:
http://ski-ride.co.uk/guides/les-deux-alpes/street-map

Kind regards

Francis J (SnowBeard)

Klokan Petr Pridal

unread,
Jul 8, 2010, 5:07:43 AM7/8/10
to MapTiler User Group
Francis,

You need to add the test into the getTileUrl function if the bounds of
the requested tile (at the position coord.x, coord.y, zoom) are
overlapping the bounding box of your overlay or not - and based on
that return "none.png" or the correct overlay tile url.

Check http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/,
there is all the math you need to make the test.

You can also use this.getProjection() to get the MapCanvas Projection
object http://code.google.com/apis/maps/documentation/javascript/reference.html#MapCanvasProjection
and then work with pixel coordinates modulo 256 - to determine if the
requested tile is inside of the bounding box of your overlay or not.

I would like to upgrade MapTiler templates to V3 in some of the future
versions...

Anybody from MapTiler users interested in doing this work?

Klokan Petr Pridal

On Jun 10, 9:01 pm, SnowBeard <fran...@ski-ride.co.uk> wrote:
> Hi Klokan
>
> Firstly, massive thanks for producing Maptiler - it rocks!
> I've created a mash-up for V3 using your Grand Canyon example code
> snippet, and with the help of my 2 lovely assistants Miss Cut & Miss
> Paste; everything looks ok and it appears to work well, but I've
> noticed in my site stats that I'm getting a lot of 404 errors for .png
> tiles which probably lie outside the bounds of my custom map. Have you
> experienced anything similar with V3?
> I'm guessing it's because the getTileUrl function doesn't have any way
> to set the map bounds or any /none.png redirect like Maptiler does as
> standard for V2; and I can't find any reference for any setBounds or
> similar in the official Google Maps V3 API tutorial/reference.
> I can handle the problem using .htaccess redirects of course, but
> there must be an easier and more elegant way. Probably using an 'if'
> function in the javascript, but I'm just a beginner with js and I
> haven't worked that out yet. Any ideas greatly appreciated.
> Here's the url of a page displaying the first of my V3 examples:http://ski-ride.co.uk/guides/les-deux-alpes/street-map
>
> Kind regards
>
> Francis J (SnowBeard)
>
> > --http://blog.klokan.cz/http://www.maptiler.org/http://www.oldmapsonlin...
Reply all
Reply to author
Forward
0 new messages