[Users] remove popup

Luis Miguel Royo Pérez luis.miguel.royo at gmail.com
Wed Apr 9 19:21:29 CEST 2014


Hi everyone,

I'm new with Geoext, and I got some troubles to remove a popup when this 
is unselected. The code I'm using for create the Popup is below:

var report = function(e) {
                 OpenLayers.Console.log(e.type, e.feature.id)};

   var highlightCtrl = new OpenLayers.Control.SelectFeature(espana, {

                 hover: false,
                 highlightOnly: true,
                 renderIntent: "temporary",
                 eventListeners: {
                     beforefeaturehighlighted: report,
                     featurehighlighted: report,
                     featureunhighlighted: report
                 }
             });

             var selectCtrl = new OpenLayers.Control.SelectFeature(espana,
                 {clickout: true}
             );

            map.addControl(highlightCtrl);
             map.addControl(selectCtrl);

             highlightCtrl.activate();
             selectCtrl.activate();

         // define "createPopup" function

     function createPopup(feature) {
         popup = new GeoExt.Popup({
             title: 'My Popup',
             location: feature,
             width:200,
             html: feature.attributes.NOMBRE99,
             maximizable: true,
             collapsible: true
         });
         // unselect feature when the popup
         // is closed
         popup.on({
             close: function() {
if(OpenLayers.Util.indexOf(espana.selectedFeatures,
                                            this.feature) > -1) {
                     selectCtrl.unselect(this.feature);
                 }
             }
         });

         mapPanel.remove(popup);


         popup.show();
     }



     // create popup on "featureselected"
     espana.events.on({
         featureselected: function(e) {
             createPopup(e.feature);
         }
     });

Any idea is wellcomed. Thanks a lot per advance!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20140409/72e8f62e/attachment.htm 


More information about the Users mailing list