[Users] GeoExt Popup / GetFeatureInfo, how do I destroy the popup if it exists?

Matt Priour mpriour at kestrelcomputer.com
Mon Sep 20 21:39:07 CEST 2010


See added code below
Matt Priour
Kestrel Computer Consulting


From: Andrew Stewart 
Sent: Monday, September 20, 2010 1:51 PM
To: 'users at geoext.org' 
Subject: [Users] GeoExt Popup / GetFeatureInfo, how do I destroy the popup if it exists?


Below is my code for when I hover over a specific layer and the popup hotspot information is shown. I am trying to figure out how to only get one popup to show at a time so that I can show them like tooltips and destroy the existing one if another is shown. I have tried using if (infopop) or if (!infopop) but this doesn't seem to work in the way I have this coded. If anyone has any advice on how to destroy my popup when another is created thanks!






var info, infopop;
        
        //Getfeatureinfo object
        info = new OpenLayers.Control.WMSGetFeatureInfo({
                        url: 'http://ITS701X5J1/RedWMS/Request.aspx', 
            title: 'Identify features by clicking',
            layers: [layer_Garbage_Zones],
            queryVisible: true,
            infoFormat: 'text/html',
            maxFeatures: 1,
            hover:true
            });
          
            info.events.on({
              getfeatureinfo: function(e) {
              <ADDED CODE - begin>

            //get all existing popups
            var popups = Ext.WindowMgr.getBy(function(win){return (win instanceof GeoExt.Popup)});

            //kill all existing popups
            popups.each(function(popup){popup.destroy()});

            <ADDED CODE - end>
             infopop =  new GeoExt.Popup({      //utilizing the GeoExt popup functionality
                   title: "Hotspot Information",
                    //height: 215,
                    //width: 600,
                                        autoWidth: true,
                                        autoHeight: true,
                                        autoScroll: false,
                  //  panIn: true,
                    map: map,
                    lonlat: map.getLonLatFromPixel(e.xy),
                    html: e.text
                })
                
                    etext = e.text;
                       // if the hotspot information is empty (layer doesn't match) don't display!
               if (etext.length == 45)
                    {
                            infopop.close();
                    }
                    else
                    {
                        infopop.show();
                    }
                }});
            
                
        map.addControl(info);
     info.activate();




--------------------------------------------------------------------------------
This e-mail is intended for the original recipient(s) only. If you have received it in error, please advise the sender and delete this message. 



--------------------------------------------------------------------------------


_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100920/7c650461/attachment.htm 


More information about the Users mailing list