I'm trying to format the attributes of a WMS layer myself.
The WMS layer is made from a shapefile using Geoserver.
Using Google I found this piece of code:
var infoControl = new OpenLayers.Control.WMSGetFeatureInfo({
url: serverLocation,
title: 'Get data',
queryVisible: true,
infoFormat: 'application/vnd.ogc.gml',
output: 'features',
eventListeners: {
getfeatureinfo: function(event) {
console.log(event.features.length);
for (var i = 0; i < event.features.length; i++) {
var feature = event.features[i];
var attributes = feature.attributes;
console.log(attributes);
document.getElementById('info').innerHTML =
attributes[0];
}
}
}
});
map.addControl(infoControl);
infoControl.activate();
This doesn't do anything because event.features.length is zero.
When I change the infoFormat to text and put event.text in my div I get the
default formatted table.
So the response is correct.
When I use Firebug and look at the response of the GET that is send, I see
my data in xml format.
So what am I missing that I cannot parse that xml into the event.features
class.
Thanks,
Paul
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users