0

I am using the WMSGetFeatureInfo control to retrieve feature attributes from geoserver and display in popups.

I've setup the proxyhost at localhost and the popup is working fine now. I am using eventListeners.

After it executes the last line, map.addPopup(popup), the layout of the html file changes as shown in the attached images.

The codes is as below:

shelter_info = new OpenLayers.Control.WMSGetFeatureInfo ({
    url:"http://130.95.44.145:8080/geoserver/Bushfire_Com_Study/wms",
    title: 'Identify features by clicking',
    layers:[evacuation_center],
    queryVisible: true,
    hover: true,
    eventListeners:{
        getfeatureinfo: function(event){
            //only display popup when selected the WMS object
            if (event.text.indexOf("<table class=\"featureInfo\">") != -1) { 
                var popup = new OpenLayers.Popup.FramedCloud(
                    "shelter_popup",
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true,
                    null
                );
                popup.autoSize = true;
                popup.minSize = new OpenLayers.Size(180,180);
                map.addPopup(popup);
            }
        }                     
    }
});

Before adding popups:
https://flic.kr/p/nACiDZ

After adding popups:
https://flic.kr/p/nACqxC

Iain Samuel McLean Elder
  • 19,791
  • 12
  • 64
  • 80
CathyCao
  • 11
  • 3
  • Hi @user, do you mean the layout changes when the event listener fires? or just by inclusion of that line in the code? If you inspect-element with your browser do the tables in the Legend use the class name `featureInfo`? because in the 2nd pic it looks like the legend is styled like a popup `featureInfo` table. – OGHaza May 13 '14 at 10:40
  • Hi @OGHaza, thanks for your reply! Yes, I meant it changes every time after the event listener fires. That sounds like a likely reason. but I didn't define any class for the legend tables. in the pic 2, it looks like every single table, td and th are bordered, so it's a change of style of all the tables? in the css I've only styled html, body, and all the other styles are for specific IDs. – CathyCao May 13 '14 at 11:47
  • If you inspect element on the table in the legend and see that it is using `class="featureInfo"` or similar, you definitely need to change it to use a class of another name. This is difficult to debug without having the a working example to play with. – OGHaza May 13 '14 at 11:57
  • Hi @OGHaza, I just found the problem! I was playing with the Geoserver style templates and created a table style file at global level. after deleting it the problem doesn't exist. Thanks so much! – CathyCao May 13 '14 at 13:08
  • Glad you worked it out ;) – OGHaza May 13 '14 at 13:10

0 Answers0