Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've managed to get features return by a WFS filter layer but I can't add them on top a google map layer.

    var map, Geographic, Mercator, wfsLayer;

    OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
    OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";



        WGS84 = new OpenLayers.Projection("EPSG:4326");
        WGS84_google_mercator = new OpenLayers.Projection("EPSG:900913");


        var map = new OpenLayers.Map('map');
        map.addControl(new OpenLayers.Control.LayerSwitcher());
        var google_maps = new OpenLayers.Layer.Google("Google Maps");
        map.addLayer(google_maps);

    var mapextent = new OpenLayers.Bounds(-62.6465189999999, -27.60586, -54.25863, -19.291371).transform(WGS84, WGS84_google_mercator);
    map.zoomToExtent(mapextent);        

        wfsLayer = new OpenLayers.Layer.Vector("WFS", {
    styleMap: new OpenLayers.StyleMap({
                strokeWidth: 3,
                strokeColor: "#333333"
            })
    });
        map.addLayer(wfsLayer);


        var _CallBack = function (resp) {

            if (resp.error) {
                console.log('error');
                return -1;
            }

            wfsLayer.addFeatures(resp.features);
            console.log('success - features returned: ' + resp.features.length);
            return 1;
        };


        var QueryWFSService = function () {

            var prot = new OpenLayers.Protocol.WFS({
                url: "http://172.16.234.132:8082/geoserver/wfs/cite",
                featureType: "administrative_layer",
                featureNS: "http://172.16.234.132/cite",
                defaultFilter: new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "NAME_1",
                        value: "Itapa"
        })
            });

            prot.read({
                callback: _CallBack
            });

        };

        map.events.register("moveend", map, QueryWFSService);

        QueryWFSService();

The thing is that if I change the google_map layer, for a wms layer and remove the transform from

 var mapextent = new OpenLayers.Bounds(-62.6465189999999, -27.60586, -54.25863, -19.291371).transform(WGS84, WGS84_google_mercator);

It works well, and features are drawed. So I think it's about the projections, but I'm lost.

Any help will be appreciated. Thanks,

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.