Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to get attributes of feature using getFeatureInfo:

if(sss==null){
   if (sld==null){
     sld= new OpenLayers.Control.WMSGetFeatureInfo({
    url: 'http://localhost:8080/geoserver/wms', 
    title: 'Identify',
    layers: myLayer,
    queryVisible: true
     });
   app.mapPanel.map.addControl(sld);
   sss=app.mapPanel.map.getControlsBy('title', 'Identify');
}                                   
}
for(var i=0;i<sss.length;i++){
alert("BROMACIA");
 sss[i].activate();
}
sss[0].events.register("getfeatureinfo", app.mapPanel.map, function showInfo(evt) {
alert(evt.text)});

And nothing heppens.
When i try to do in firebug:

>>> sss[0].events.register("getfeatureinfo", app.mapPanel.map, function showInfo(evt) { alert(evt.text)});

firebug says undifined.

Whats wrong?

share

1 Answer 1

up vote 1 down vote accepted

Solution:

if(sss==null){
if (sld==null){
 sld= new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/wms', 
title: 'Identify',
layers: myLayer,
queryVisible: true
 });
app.mapPanel.map.addControl(sld);
sss=app.mapPanel.map.getControlsBy('title', 'Identify');
}                                   
}
function showInfo(evt) {
lert(evt.text);
}
for(var i=0;i<sss.length;i++){
  alert("BROMACIA");
  sss[i].activate();
  sss[i].events.register("getfeatureinfo", app.mapPanel.map, showInfo);
}
share

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .