1

I would like to overlay a polygon layer on Google map API V3 from a WFS output file in GML2 format from a remote WFS server. No other output format is available in the WFS server.

Is it possible to do this using GeoXML3 ?

It would be great if some can give me a demo link which using a GML2.

1 Answer 1

1

GeoXML is for processing KML in the browser. GML is not KML, so that won't work. You can overlay GML on Google Maps API v3 using OpenLayers. I can't find a demo link, but here is an example:

<!DOCTYPE html>
<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
        <title>Google Maps API v3 and WFS</title>
        <link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css">
        <link rel="stylesheet" href="http://openlayers.org/dev/theme/default/google.css" type="text/css">

        <link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css">
        <script src="http://maps.google.com/maps/api/js?v=3.5&amp;sensor=false"></script>
        <script src="http://openlayers.org/dev/lib/Firebug/firebug.js"></script>
        <script src="http://openlayers.org/dev/OpenLayers.js"></script>
        <script type="text/javascript">
          var map;

        function init() {
            OpenLayers.ProxyHost= "proxy.cgi?url=";
            map = new OpenLayers.Map('map');
            map.addControl(new OpenLayers.Control.LayerSwitcher());

            var gphy = new OpenLayers.Layer.Google(
                "Google Physical",
                {type: google.maps.MapTypeId.TERRAIN}
            );

            var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
            renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;

            var wfs = new OpenLayers.Layer.Vector("States", {
                    strategies: [new OpenLayers.Strategy.BBOX()],
                    protocol: new OpenLayers.Protocol.WFS({
                        url: "http://demo.opengeo.org/geoserver/wfs",
                        featureType: "states",
                        featureNS: "http://www.openplans.org/topp"
                    }),
                    renderers: renderer
                });

            map.addLayers([gphy, wfs]);

            // Google.v3 uses EPSG:900913 as projection, so we have to
            // transform our coordinates
            map.setCenter(new OpenLayers.LonLat(-98.5795, 39.828175).transform(
                new OpenLayers.Projection("EPSG:4326"),
                map.getProjectionObject()
            ), 3);

        }

        </script>
    </head>
    <body onload="init()">
        <h1 id="title">Google (v3) Layer Example + WFS</h1>
        <p id="shortdesc">
            Demonstrate use the Google Maps v3 API with WFS.
        </p>
        <div id="map" class="smallmap"></div>
    </body>
</html>

A couple of caveats:

  • the script pulls the stylesheets and OpenLayer.js from the OpenLayers site, you will want to change that to your local install of OpenLayers
  • you will need to set up a proxy since you are requesting GML from a site outside your domain, please see http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost
  • the mapping portion (init()) is often written as a separate javascript file, but it's included here to be explicit
2
  • Thank you Sophia for your answer. I think here we are using Openlayers not Googlemap API V3. I am using Openlayers to pull the WFS GML data, Now I want to Overlay this Polygon over googlemaps API V3.
    – sur
    Commented Sep 8, 2011 at 10:39
  • Here is a link This is Google Map API V2 and I could not see a good example. Here is another link to a presentation( search for google_wfs_arch in google the first lik).Unfortunately their demo links are not working. I think It is possible but still looking for a good example which uses real GLM2 from WFS.
    – sur
    Commented Sep 8, 2011 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.