2

I have a map with points from GeoJSON file. I created a default style and a select style for these points. I created a popup with attributes from GeoJSON when clicking on a point. All works fine, except that I can't close the popup: the point is unselected, but the popup still remains even if I use the red cross. I read this post that seems to deal with the same issue, but I can't use it in my application.
Thanks for your help

code for popup :

selection = new OpenLayers.Control.SelectFeature(operationCentroide);

    operationCentroide.events.on({
        "featureselected": monpopup,
        "featureunselected": onFeatureUnselect
    });

    map.addControl(selection);
    selection.activate();

    function onPopupClose(evt) {
        selection.unselectAll();
    }

    function monpopup(event) {
        var feature = event.feature;
        var contenu = feature.attributes.numope;
        popup = new OpenLayers.Popup.FramedCloud("chicken",
            feature.geometry.getBounds().getCenterLonLat(),
            new OpenLayers.Size(100,100),
            contenu,
            null, true, onPopupClose);
            map.addPopup(popup);
    }

    function onFeatureUnselect(event) {
        var feature = event.feature;
        if(feature.popup) {
            map.removePopup(feature.popup);
            feature.popup.destroy();
            delete feature.popup;
        }
    }enter code here
1

I got it : I just deleted onPopupClose from popup definition in function monpopup(event). Now white cross does its job

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.