[GIS] How to display clickable features from Geoserver over Google Maps v3 Base

geoservergoogle mapswfs

Please forgive what I am sure is a very noob question, but I need to do some research into the best way to achieve this and I am a beginner to GIS.

My employer has a Geoserver instance set up which can serve up files in all manner of formats. Is it possible to plot one of these onto Google Maps v3 in such a way as to make the feature's properties available to an information pop-up?

My development server is not on the same domain as the Geoserver, but the Geoserver serves up files publicly.

I have tried using GeoJSON but this seems to rely on the Geoserver and web server being on the same domain, otherwise cross site scripting protection prevents the connection – this works fine as long as I download the GeoJSON into a text file and store it on the web server but the source database will be regularly updated so the mapping needs to be dynamic.

I've tried using a KML layer, but nothing displays at all when I use this method replacing the KML file URL with my own Geoserver's KML file url.

I think this must not be a weird question as having a map with features that pop up info when you click them seems to be a fairly common thing, so can someone advise me where to start?

e.g. What is the best format to use to serve up dynamically updated data from Geoserver? Is it possible to display this kind of info on Google Maps? I believe that this needs to be a web feature service in order to plot vector objects rather than image-based maps – how would you handle this kind of request?

Best Answer

You need to implement a WebGIS application which base layer is provided by Google Maps and which main feature layer is provided by your employer GeoServer instance. For this purpose you may use the excellent open source library OpenLayers. In its home site you can find tutorials and examples which can help you to implement your application. Alternatively you may use maps provided by OpenStreetMap or other open data services in your application.

Web browsers prevent applications from performing AJAX requests to domains different from domain serving the application. Therefore this will prevent your application to reach data provided by the GeoServer instance. For avoiding this limitation you may enable cross-origin resource sharing (CORS) in the GeoServer instance. You can find more information about CORS in this web site.