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

Andrew Stewart Andrew.Stewart at reddeer.ca
Mon Sep 20 21:49:00 CEST 2010


 Thanks for your suggestion, I tried to use your suggested code but I am getting a Javascript error after hovering over my layer, which states -

Message: Unspecified error.
Line: 1188
Char: 1
Code: 0
URI: http://localhost/WebServices/OpenLayers-2.10/OpenLayers.js

which is this line in OpenLayers.js but not sure exactly what's wrong. I do appreciate your assistance.


this._object.send(vData);if(bGecko&&!this._async){this.readyState=cXMLHttpRequest.OPENED;fSynchronizeValues(this);while(this.readyState<cXMLHttpRequest.DONE){this.readyState++;fReadyStateChange(this);if(this._aborted)



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)
              {
            //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",
                    autoWidth: true,
                    autoHeight: true,
                    autoScroll: false,
                    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();


________________________________
From: Matt Priour [mailto:mpriour at kestrelcomputer.com]
Sent: September 20, 2010 1:39 PM
To: Andrew Stewart; users at geoext.org
Subject: Re: [Users] GeoExt Popup / GetFeatureInfo, how do I destroy the popup if it exists?

See added code below
Matt Priour
Kestrel Computer Consulting

From: Andrew Stewart<mailto:Andrew.Stewart at reddeer.ca>
Sent: Monday, September 20, 2010 1:51 PM
To: 'users at geoext.org'<mailto:'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

________________________________
[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100920/725845bf/attachment-0001.htm 


More information about the Users mailing list