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?