<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859-1>
<META content="MSHTML 6.00.6002.18278" name=GENERATOR><!-- converted from rtf -->
<STYLE><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></STYLE>
</HEAD>
<BODY id=MailContainerBody
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px" leftMargin=0
topMargin=0 CanvasTabStop="true" name="Compose message area">
<DIV><FONT face=Arial size=2>See added code below</FONT></DIV>
<DIV><FONT face=Arial size=2>Matt Priour</FONT></DIV>
<DIV><FONT face=Arial size=2>Kestrel Computer Consulting</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><FONT face=Arial></FONT><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=Andrew.Stewart@reddeer.ca
href="mailto:Andrew.Stewart@reddeer.ca">Andrew Stewart</A> </DIV>
<DIV><B>Sent:</B> Monday, September 20, 2010 1:51 PM</DIV>
<DIV><B>To:</B> <A title=users@geoext.org
href="mailto:'users@geoext.org'">'users@geoext.org'</A> </DIV>
<DIV><B>Subject:</B> [Users] GeoExt Popup / GetFeatureInfo, how do I destroy the
popup if it exists?</DIV></DIV></DIV>
<DIV><FONT face=Arial size=2></FONT><BR></DIV><FONT face="Arial, sans-serif"
size=2>
<DIV>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!</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>var info, infopop;</DIV>
<DIV> </DIV>
<DIV> //Getfeatureinfo object</DIV>
<DIV> info = new
OpenLayers.Control.WMSGetFeatureInfo({</DIV>
<DIV>
url: '<A href="http://ITS701X5J1/RedWMS/Request.aspx"><FONT
color=#0000ff><U>http://ITS701X5J1/RedWMS/Request.aspx</U></FONT></A>', </DIV>
<DIV> title:
'Identify features by clicking',</DIV>
<DIV> layers:
[layer_Garbage_Zones],</DIV>
<DIV>
queryVisible: true,</DIV>
<DIV> infoFormat:
'text/html',</DIV>
<DIV> maxFeatures:
1,</DIV>
<DIV>
hover:true</DIV>
<DIV> });</DIV>
<DIV> </DIV>
<DIV>
info.events.on({</DIV>
<DIV>
getfeatureinfo: function(e) {</DIV>
<DIV>
<ADDED CODE - begin></DIV>
<DIV> </DIV>
<DIV> //get
all existing popups</DIV>
<DIV> var
popups = Ext.WindowMgr.getBy(function(win){return (win instanceof
GeoExt.Popup)});</DIV>
<DIV> </DIV>
<DIV> //kill
all existing popups</DIV>
<DIV> popups.each(function(popup){popup.destroy()});</DIV>
<DIV> </DIV>
<DIV> <ADDED
CODE - end></DIV>
<DIV>
infopop = new GeoExt.Popup({ //utilizing the
GeoExt popup functionality</DIV>
<DIV>
title: "Hotspot Information",</DIV>
<DIV>
//height: 215,</DIV>
<DIV>
//width: 600,</DIV>
<DIV>
autoWidth: true,</DIV>
<DIV>
autoHeight: true,</DIV>
<DIV>
autoScroll: false,</DIV>
<DIV>
// panIn: true,</DIV>
<DIV>
map: map,</DIV>
<DIV>
lonlat: map.getLonLatFromPixel(e.xy),</DIV>
<DIV>
html: e.text</DIV>
<DIV>
})</DIV>
<DIV>
</DIV>
<DIV>
etext = e.text;</DIV>
<DIV>
// if the hotspot information is empty
(layer doesn't match) don't display!</DIV>
<DIV>
if (etext.length == 45)</DIV>
<DIV>
{</DIV>
<DIV>
infopop.close();</DIV>
<DIV>
}</DIV>
<DIV>
else</DIV>
<DIV>
{</DIV>
<DIV>
infopop.show();</DIV>
<DIV>
}</DIV>
<DIV>
}});</DIV>
<DIV> </DIV>
<DIV>
</DIV>
<DIV> map.addControl(info);</DIV>
<DIV> info.activate();</DIV>
<DIV> </DIV>
<DIV> </DIV></FONT>
<DIV>
<P>
<HR>
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.
<P></P></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Users mailing
list<BR>Users@geoext.org<BR>http://www.geoext.org/cgi-bin/mailman/listinfo/users<BR></BODY></HTML>