[OpenLayers-Users] Popup can not be closed when zooming

Asle Benoni asle.benoni at gmail.com
Sun Jun 7 09:33:44 EDT 2009


Hi,
I did not understand this as I cannot find "Moveend" as a defined event. Or
maybe I am missing something.
I have the following function under to define the popup box. I tried to
write the checkPopup function without success:

            // popup box
          selectControl = new
OpenLayers.Control.SelectFeature(map.layers[5],{onSelect: onFeatureSelect,
onUnselect: onFeatureUnselect});
           map.addControl(selectControl);
           selectControl.activate();

           function onPopupClose(evt) {
                selectControl.unselect(selectedFeature);
            }

        function onFeatureSelect(feature) {
            selectedFeature = feature;
            popup = new OpenLayers.Popup.FramedCloud("chicken",

feature.geometry.getBounds().getCenterLonLat(),
                                     new OpenLayers.Size(100,200),
                    "<h2>" +feature.attributes.gardsnavn +
                    "</h2>Type: "+ feature.attributes.art +
                     "<br />Kommune: "+ feature.attributes.komm +
                     "<br />Beskrivelse<br /><a href='" +
feature.attributes.urltilpdfark +
                     "' target=blank><img src='
http://naturkart.no:8080/geoserver/images/logo.png' border='0'
alt='naturkart'></a>", null, true, onPopupClose);
            feature.popup = popup;
            map.addPopup(popup);
        }
        function onFeatureUnselect(feature) {
            map.removePopup(feature.popup);
            feature.popup.destroy();
            feature.popup = null;
        }
        function checkPopup(feature) {
            if (feature.popup!= null){
            feature.popup.destroy();
            }
        }

        map.events.register("moveend", map, checkPopup);


/asle

2009/6/4 Alexandre Dube <adube at mapgears.com>

> Hi,
>
> Register a "moveend" event to your map objet :
>
> yourMapObj.events.register("moveend", yourMapObj, checkPopup)
>
> Then, in your checkPopup function, check your map if it has any popup and
> destroy them.
>
> Regards,
>
> Alexandre
>
> Asle Benoni wrote:
>
>> Hello,
>> I have some popups from a WFS layer and a KML layer . When I click the
>>  point the popup shows. If I zoom in or out without closing the popup  the
>> popup stays and I cannot close it. Is there a way to automatically  close
>> any popups that are open when zooming in or out?
>>
>> Thanks for any help!
>>
>> /asle
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>
>
> --
> Alexandre Dubé
> Mapgears
> www.mapgears.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090607/facab10d/attachment.html


More information about the Users mailing list