Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|improve this question
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|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.