[OpenLayers-Users] one attribute from getFeatureInfo
vrbikdan
vrbikdan at gmail.com
Tue Mar 20 06:27:43 EDT 2012
Hi all,
I'm trying to mine only one attribute from getFeatureInfo. This attribute I
need to store in variables and use it somewhere in the code. I tried change
info_format in request to xml and work with it, but without any progress.
Below is code I use:
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: "http://localhost:8080/geoserver/zk/wms",
title: 'Identify features by clicking',
queryVisible: true,
INFO_FORMAT: 'text/html',
eventListeners: {
getfeatureinfo: function(event) {
document.getElementById('get').innerHTML = event.text;
}}});
map.addControl(info);
info.activate();
This code shows me styled table, but I need only one attribute. I tried to
change code like this:
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: "http://localhost:8080/geoserver/zk/wms",
title: 'Identify features by clicking',
queryVisible: true,
INFO_FORMAT: 'text/html',
eventListeners: {
getfeatureinfo: function(event) {
xmlResponse = new OpenLayers.Format.XML().read(event.text);
document.getElementById('get').innerHTML =
xmlResponse.attribute.ZONA_AVON;//ZONA_AVON is my attribute I need to know
}}});
map.addControl(info);
info.activate();
But this writes me "undefined" and thats all. Do you have any suggestions
how to solved this?
Thanks a lot
Dan
P.S. I'm using Geoserver 2.1.3
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/one-attribute-from-getFeatureInfo-tp4636316p4636316.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list