Implementing a Google Map Layer on Geoserver

4,349 views
Skip to first unread message

elshae

unread,
Aug 24, 2010, 9:53:19 AM8/24/10
to Google Maps JavaScript API v3
Hello all,

I am new to GIS and spatial data technology. For the last week I have
been trying to figure what is the appropriate/recommended way to add a
Google Map layer to my Geoserver projects. I saw a screen shot on one
site of some sort plug-in, but have yet to find any info on that. I
have also seen http://geowebcache.org/docs/current/services/gmaps.html
but I yet to know where do I add this JavaScript snippet to implement
it. So far the only solution I have come up with is to create an HTML
document and place it in the www directory of my Geoserver with the
following snippets:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src='http://dev.virtualearth.net/mapcontrol/
mapcontrol.ashx?v=6.2&mkt=en-us'></script>
<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;sensor=false&amp; type="text/javascript"></
script>

......

// create Google layer
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: G_SATELLITE_MAP, sphericalMercator: true}
);

....

map.addLayers([gsat, veaer, yahoosat, wms]);

.....

But is the process really this manual? In Quantum GIS there's an easy
out-of-the-box plug-in that I click on and a Google Layer is generated
for my spatial data. My other question is, why is the API key
needed? I didn't use it in this case and I have read in articles that
it isn't needed for the v3 API. Does this key only apply to some of
the Google MAp API's and not others?

I apologize in advance if I am asking the obvious :)

Cheers,

elshae

elshae

unread,
Aug 24, 2010, 10:13:36 AM8/24/10
to Google Maps JavaScript API v3
I apologize, my script
<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;sensor=false&amp; type="text/javascript"></
script>

Should have been
<script src="http://maps.google.com/maps?
file=api&amp;v=3&amp;sensor=false&amp; type="text/javascript"></
script>

On Aug 24, 9:53 am, elshae <itinte...@trace.org> wrote:
> Hello all,
>
> I am new to GIS and spatial data technology.  For the last week I have
> been trying to figure what is the appropriate/recommended way to add a
> Google Map layer to my Geoserver projects.  I saw a screen shot on one
> site of some sort plug-in, but have yet to find any info on that.  I
> have also seenhttp://geowebcache.org/docs/current/services/gmaps.html

Rossko

unread,
Aug 24, 2010, 12:48:01 PM8/24/10
to Google Maps JavaScript API v3
>             var gsat = new OpenLayers.Layer.Google(

Whatever example you are looking at, it is an OpenLayers example.
That is a client-side mapping display tool, which can optionally show
Google's mapping imagery via the use of Google's own maps API in
addition to the OpenLayers code.

> I am new to GIS and spatial data technology. For the last week I have
> been trying to figure what is the appropriate/recommended way to add a
> Google Map layer to my Geoserver projects.

So far as I know, Geoserver is just that, a server, and you won't be
able or allowed to add Google maps to it. For Geoserver to be any
practical use, you have to view it with some client-side app or
another ... like OpenLayers, for example. If you want to include
Google maps for user view, its the client-side you should be looking
into.

elshae

unread,
Aug 24, 2010, 3:41:11 PM8/24/10
to Google Maps JavaScript API v3
Thank you for your quick reply Rossko!

Well I think I finally got it.
It seems that the only way to do it is to create an HTML file and save
it in Geoserver's /www directory. This HTML file has all the
OpenLayers and Google Layer JavaScript snippets needed to customize my
map using the API's. I was hoping that there would be some sort of
plug-in for OpenLayers, but all documentation points to manual
JavaScripting. If anyone has any info on a generic way to implement
OpenLayers and Google Map Layers please let me know! Otherwise I
would recommend this http://lsi.iiit.ac.in/osgeoin/sites/default/files/GeoServer_tutorial.pdf
. Note that the Geoserver version used in this documentation seems to
be different than the current and some of the instructions are a
little off, but it still gives a great gist and there are still ways
to follow every step.

Cheers,

elshae
Reply all
Reply to author
Forward
0 new messages