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
No comments:
Post a Comment