[OpenLayers-Users] Close a popup when another is open

Eric Lemoine eric.lemoine at camptocamp.com
Thu Jan 19 02:55:49 EST 2012


2012/1/19 Juan Jesús Cremades Monserrat <relicary at gmail.com>:
> Hi,
>
> I have the next code to show a popup when a user clicks over the map:
>
>
> info = new OpenLayers.Control.WMSGetFeatureInfo({
> url : 'http://localhost:9000/cgi-bin/mapserv.exe',
> title : ' ',
> layers : [ StatesWms ],
> queryVisible : true,
> vendorParams : {
> map : '/ms4w/apps/demo-cv/demoCV.map'
> },
> eventListeners : {
> 'getfeatureinfo' : function(event) {
> var popup = new
> OpenLayers.Popup.FramedCloud("Datos",map.getLonLatFromPixel(event.xy),
> null, event.text, null, true);
> popup.autoSize = true;
> map.addPopup(popup);
> }
> }
> });
>
> map.addControl(info);
> info.activate();
>
> When I click over the map, the popup with the correct information appears at
> the web client, but I want that if I click in another point, the first popup
> will be closed and the new will be open. Some help?

See the exclusive parameter to addPopup:
<http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.addPopup>.



-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com


More information about the Users mailing list