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!!!
_______________________________________________
Users mailing list
Users@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Reply via email to