[OpenLayers-Users] Geoserver WFS vector layer problem

Rose Hamilton roseham at iafrica.com
Tue Feb 7 07:11:59 EST 2012


I’m developing my first web mapping site and I’m having a problem showing a
vector layer served by GeoServer WFS in my map. I've looked at many similar
issues reported in various discussion forums and am still at a loss. I’m
using Apache 2.2 and Geoserver 2.1.2. My vector layer code:	
layerApps = new OpenLayers.Layer.Vector("Development Applications", {
		strategies: [new OpenLayers.Strategy.BBOX()],
		protocol: new OpenLayers.Protocol.WFS({
		  url:  "http://localhost:8080/geoserver/wfs",
		  featureType: "dev_apps",
		  featureNS: "http://localhost/cdp",
		  srsName: "epsg:4326",
		  version: "1.1.0"                    
		  })
	});
	map.addLayer(layerApps);

GeoServer is on the same server but if I don’t use a proxy, Google Developer
Tools shows the following error:
“XMLHttpRequest cannot load http://localhost:8080/geoserver/wfs. Origin
http://localhost is not allowed by Access-Control-Allow-Origin.”
I’m now using the proxy.cgi file from OpenLayers website and have added
‘localhost’, ‘localhost:8080’, ‘localhost:80’ in the AllowedHosts list. I’ve
installed Python and changed the first line in proxy.cgi to
#!C:/python27/python.exe –u
In Geoserver, my Namespace URI is http://localhost/cdp
The map loads okay (no errors reported) but the vector layer does not show.
If I look at the HTML tab in Firebug Lite, I see the following:
<div id="OpenLayers.Layer.Vector_91" style="position: absolute; width: 100%;
height: 100%; z-index: 355; left: 0px; top: 0px;" dir="ltr"
class="olLayerDiv">
<svg id="OpenLayers.Layer.Vector_91_svgRoot" width="570" height="620"
viewbox="0 0 570 620">
<g id="OpenLayers.Layer.Vector_91_root" style="visibility: visible; "
transform="">
<g id="OpenLayers.Layer.Vector_91_vroot"/>
<g id="OpenLayers.Layer.Vector_91_troot"/>
</g>
</svg>
</div>

If I type ‘map.layers[6].features’ in the Firebug Lite  console, it returns
[]. I gather OpenLayers is not retrieving data from Geoserver. Anyone got
any ideas?

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Geoserver-WFS-vector-layer-problem-tp4372271p4372271.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list