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.

Possible Duplicate:
How to add GeoServer wfs layer on OpenLayers?

I'm really new to this and am making a map for a university project, I can't get my WFS layer to show up on my map, the WMS layer shows up fine, just no WFS layer, here is my code:

Ext.onReady(function() {

var map = new OpenLayers.Map('map');

map.addControl(new OpenLayers.Control.OverviewMap());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.MouseToolbar());
map.addControl(new OpenLayers.Control.KeyboardDefaults());

var base = new OpenLayers.Layer.WMS(
"UK base map",
"http://localhost:8080/geoserver/wms",
{layers: "topp:GBR_adm2"}
);
map.addLayer(base);

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

var wfs = new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
url: "http://localhost:8080/geoserver/wfs",
featurePrefix: "topp",
featureType: "reptiles_amphibians_locations",
featureNS: "http://www.openplans.org/topp",
srsName: "EPSG:4326",
geometryName: "the_geom"
})
});
map.addLayer(wfs);

var mappanel = new GeoExt.MapPanel({
region:"center",
height: 400,
width: 600,
map: map,
title: 'UK Distribution'
});

var layerList = new GeoExt.tree.LayerContainer({
text: 'Species',
layerStore: mappanel.layers,
leaf: false,
expanded: true
});

var layerTree = new Ext.tree.TreePanel({
title: 'Map Layers',
maxWidth: 500,
region: "east",
collapsible: true,
collapsed: true,
root: layerList
});

mainPanel = new Ext.Panel({
height: 600,
renderTo: "mainpanel",
layout: "border",
items: [mappanel,layerTree]
});

});

I keep reading that it could be due to the fact i'm not using a proxy, but its on localhost:8080, so does it still need one? It could be a geoserver problem. Its been driving me mad for weeks, any help would be much appreciated.

Thanks

Will

share|improve this question

marked as duplicate by iant, underdark Feb 19 '12 at 19:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer 1

I have had similar problems last week. Please check out here.

What I found out in my case:

  • No need for proxy if working on / from localhost
  • WFS won't display if you "double-click" on the html file containing your script. Your html file must be within the web directory of Geoserver and called from http://localhost:8080/geoserver/something...

Hope that helps!

share|improve this answer
add comment

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