Take the 2-minute tour ×
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 have a simple set of 99 polygons loaded into GeoServer from PostGIS. They were loaded from GeoJSON using ogr2ogr. (I'm using OpenGeo Suite 3.1 if it matters.) When I go to the layer preview and select OpenLayers it does display successfully. When I copy pasted the code and adjusted it slightly it also worked on the different server. However, now I'm trying to overlay it on top of a Bing base map. The base map displays just fine. The overlay does not display. (That is in Chrome, in Firebug it fails on map.addLayer() and aborts the entire script.)

Based on that walk through it would seem that the problem is somewhere in my declaration of the vector layer. BTW, I went into the geoserver workspace area and explicitly set the URI to what is listed under "featureNS." I've tried both declaring and not declaring the geometry name explicitly.

function init()
{   
    var map = new OpenLayers.Map("map");

    var road = new OpenLayers.Layer.Bing({
         name: "Road",
         key: apiKey,
         type: "Road"
        });
        var aerial = new OpenLayers.Layer.Bing({
            name: "Aerial",
            key: apiKey,
            type: "Aerial"
        });//,{isBaseLayer: false});*/
        var hybrid = new OpenLayers.Layer.Bing({
            key: apiKey,
            type: "AerialWithLabels",
            name: "Bing Aerial With Labels"
        });

        map.addLayers([road, hybrid, aerial]);

    var data = new OpenLayers.Layer.Vector(
    "WFS Display", 
    {   
        protocol: new OpenLayers.Protocol.WFS ({
        version: "1.1.0",
        url: "http://<servername:port>/geoserver/opengeo/wfs",
        featurePrefix: "opengeo",
        featureType: "ogrgeojson1",
        featureNS: "http://<servername:port>/data/opengeo"
    }),
        strategies: [new OpenLayers.Strategy.Fixed()]
    });

    map.addLayer(data);
}

Any thoughts? Just for the heck of it I tried using OSM instead of Bing (although that's the job) and still no joy. So it isn't Bing at least. What did I do stupid?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If projection of your data layer differ from projection of base layer (OSM or Bing in your case) you should point it directly within your overlay definition. Also try to switch to WFS version 1.0.0 instead 1.1.0. This is part of my working project:

map = new OpenLayers.Map({
    div: "map_element",
    layers: [
        new OpenLayers.Layer.OSM(),
        new OpenLayers.Layer.Vector("States", {
            strategies: [new OpenLayers.Strategy.BBOX()],
            protocol: new OpenLayers.Protocol.WFS({
                url: "http://10.22.0.175/cgi-bin/mapserv?map=/home/wfs/wfs.map&",
                featureType: "water",
                version: "1.0.0",
                geometryName: "wkb_geometry"
            }),
            projection: 'EPSG:4326'
        })
    ],
    center: [-95.8506355, 37.163851],
    zoom: 3
});
share|improve this answer
    
Technically to pass in the projection you should be using WFS 1.1.0 (though GeoServer (at least) supports it as an extension to 1.0) –  iant Jan 24 '13 at 9:08
    
You are correct! I failed to explicitly reproject all of my layers. I guess I'm too used to Arc doing it under the hood when I add a new layer. Thank you. –  bshender Jan 24 '13 at 16:20

Your Answer

 
discard

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

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