I have a "rich" application (OL 2.13 + GeoExt 1) where some layers must be styled dynamically according to user input. I am able to add a vector layer using WFS and then apply a style rule. Recently, some users started complaining the feature is not working. Eventually I found out some WFS layers are not being portrayed in the map canvas by OL.
Below is a minimum example with a simple map and one of the
problematic layers. After loading all objects the debugger shows a
vector layer within the map
object; this vector layer is reported as
visible and with the drawn
property set to true
. In the features
array
there are 8 objects as expected, but there is nothing visible in the
map. There are no errors reported in the console.
I am able to display this same layer through WFS in QGIS and access all its attributes without trouble.
What is going wrong here?
<html>
<head>
<script type="text/javascript" src="http://localhost/spatiallib/OpenLayers-2.13.1/OpenLayers.js"></script>
<link rel="stylesheet" type="text/css" href="http://localhost/spatiallib/OpenLayers-2.13.1/theme/default/style.css">
<script type="text/javascript">
function initMap()
{
// Do not forget to add maps.iguess.tudor.lu to the proxy's allowed addresses
OpenLayers.ProxyHost = "http://localhost/cgi-bin/proxy.cgi?url=";
var mapProjection = "EPSG:31467";
var mapServicePath = "http://maps.iguess.tudor.lu/cgi-bin/mapserv?map=srv/mapserv/MapFiles/LB_localOWS_test.map";
var bounds = new OpenLayers.Bounds(3500000,5410000,3525000,5425000);
map = new OpenLayers.Map("MiniMap",{
projection: new OpenLayers.Projection(mapProjection),
units: "m",
maxExtent: bounds,
});
map.addControl(new OpenLayers.Control.LayerSwitcher());
var cityWMS = new OpenLayers.Layer.WMS(
"LB_urban_landuse",
mapServicePath,
{layers: "LB_urban_landuse",
format: "image/png",
srsName: mapProjection,
transparent: "true",
projection: new OpenLayers.Projection(mapProjection)},
{isBaseLayer: true,
visibility: true}
);
var testWFS = new OpenLayers.Layer.Vector("testWFS", {
strategies: [new OpenLayers.Strategy.Fixed()],
projection: new OpenLayers.Projection("EPSG:31467"),
visibility: true,
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
url: "http://maps.iguess.tudor.lu/cgi-bin/mapserv?map=/srv/mapserv/MapFiles/LB_localOWS_test.map",
featureNS: "http://mapserver.gis.umn.edu/mapserver",
featureType: "LB_sliders_test",
srsName: "EPSG:31467"
})}
);
map.addLayers([cityWMS, testWFS]);
map.setCenter(new OpenLayers.LonLat(3514100,5417800), 7);
testWFS.display(true);
}
</script>
</head>
<body onLoad="initMap();" style="margin:0px">
<div style="width:800px; height:600px; background:white" id="MiniMap"></div>
<input type=button value="Click for debugger" onclick="debugger;"></input>
</body>
</html>