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

Asle Benoni asle.benoni at gmail.com
Mon Jun 8 17:26:33 EDT 2009


Ok. Not really sure where to put this, when does it fire?

        function checkPopup(feature) {
            if (*feature.popup[]*= null){
            feature.popup.destroy();
            }
        }

        map.events.register("moveend", map, checkPopup);
I have FireBug but do not really know what to check :-(

Forgive my small knowledge here.

/asle


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

> Hi,
>
>  "this" in your checkPopup function is equal to you map object and it has
> no popup property but has a popups array.
>
>  Do you use firebug ?  If not, you should give it a try.
>
> Alexandre
>
> Asle Benoni wrote:
>
>> 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 <mailto: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 <mailto:Users at openlayers.org>
>>        http://openlayers.org/mailman/listinfo/users
>>
>>
>>
>>    --    Alexandre Dubé
>>    Mapgears
>>    www.mapgears.com <http://www.mapgears.com>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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/20090608/e544972b/attachment.html


More information about the Users mailing list