Help with Google Maps API access to GeoServer-GeoWebCache tiles

1,053 views
Skip to first unread message

Emilio Mayorga

unread,
Jul 29, 2011, 4:39:20 PM7/29/11
to Cascadia Users of Geospatial Open Source
I'm hoping a CUGOSIAN does this routinely and can help!

I have GeoServer layers that need to be used via Google-Maps-type
tiles by an application using the Google Maps API (ultimately, our NVS
application, http://nvs.nanoos.org); I believe it's v2 API, but I'm
not the GM developer -- and the GM developer has never used
GeoServer/GWC tiles. I do maintain and manage GeoServer. I'm using the
latest stable GeoServer, 2.1.1, via a WAR installation on Tomcat6 on
Ubuntu 10.04.

I've tested WMS access and GeoWebCache tile access using a simple
OpenLayers example:
http://habu.apl.washington.edu/mayorga/crb/crbnvs_gislayers_test5.html
Everything works. This GM-style tile request works in OpenLayers:
var gs_wtsh_wms = new OpenLayers.Layer.XYZ( "CRB Watersheds GMAP Tiles",
"http://habu.apl.washington.edu/geoserver/gwc/service/gmaps?layers=crb:crb_sub_watersheds&zoom=${z}&x=${x}&y=${y}&format=image/png",
{'sphericalMercator': true, 'isBaseLayer':false} );

According to http://geowebcache.org/docs/current/services/gmaps.html
something very similar should work in the Google Maps API. But we
can't get it to work!

I've tested a sample URL request on Firefox, like this:
http://habu.apl.washington.edu/geoserver/gwc/service/gmaps?layers=crb:crb_sub_watersheds&zoom=9&x=151&y=196&format=image/png
It doesn't return an error. It seems to return a blank 256x256 png
image. But I also can't see an entry on the GeoServer log when I issue
this request! That seems very weird.

The Google Maps requests throw errors on the GeoServer log like this:
2011-07-29 04:03:13,629 ERROR [geowebcache.GeoWebCacheDispatcher]
- Unable to determine requested format, image/png?rand_gmap=14639
http://habu.apl.washington.edu/geoserver/gwc/service/gmaps

Any clues?

Thanks!! Cheers,
-Emilio Mayorga
UW/APL/NANOOS

Emilio Mayorga

unread,
Jul 29, 2011, 5:48:42 PM7/29/11
to Cascadia Users of Geospatial Open Source
Ok, we've solved the problem. The tiles URL pattern was correct, but
there were a couple of funky issues going on.

Thanks if you were already thinking about this... Cheers,
-Emilio

Josh Livni

unread,
Jul 30, 2011, 4:24:32 PM7/30/11
to Emilio Mayorga, Cascadia Users of Geospatial Open Source
Just an FYI you should definitely be using Maps V3 -- not only is V2
is deprecated, but there's a variety of additional functionality you
may want in V3 down the line, and it's faster, compatible with
smartphones, etc.

Here's how you'd do this in V3 in case you're interested (excluding
options like adding a copyright notice, and so forth):
----

var fooLayer = new google.maps.ImageMapType({
getTileUrl: function(ll, z) {
return "http://habu.apl.washington.edu/geoserver/gwc/service/gmaps?layers=crb:crb_sub_watersheds&format=image/png&zoom="
+ z + "&x=" + ll.x + "&y=" + ll.y;
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
maxZoom: 18,
name: "Foo",
alt: "Foo Layer"
});

map.overlayMapTypes.push(fooLayer);

-----------
Cheers,

-Josh

> --
> You received this message because you are subscribed to the Google Groups "Cascadia Users of Geospatial Open Source" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cugos+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cugos?hl=en.
>
>

Emilio Mayorga

unread,
Jul 31, 2011, 4:05:15 PM7/31/11
to Josh Livni, Cascadia Users of Geospatial Open Source
Josh,

Thanks for the tip and sample. They will be useful as we plan the
transition to GM v3.
Cheers,
-Emilio

Reply all
Reply to author
Forward
0 new messages