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

Ivan Grcic igrcic at gmail.com
Thu Jun 11 10:50:01 EDT 2009


voila:

var map = toolbarExample.app.vector.map;  // MAN you really hid your
map object well :P
var bygningLayer = map.getLayersByName('Bygning')[0];

bygningLayer.events.register('loadstart', this, function (evt){
if(selectedFeature && selectedFeature.popup){
        map.removePopup(selectedFeature.popup);
        selectedFeature.popup.destroy();
        selectedFeature.popup = null;
        selectedFeature = null;
        //selectControl.unselectAll();  // you are not closing your
popup on featureUnselect so this wont work for you...
        }
})

BTW you HAVE to use some of the loading strategies, i suggest bbox at least.

cheers

On Thu, Jun 11, 2009 at 12:40 PM, Asle Benoni<asle.benoni at gmail.com> wrote:
> Thanks!
> I am not sure if I wrote this correctly. If you can take a quick look at
> http://naturkart.no/kulturminnekart/  and turn on som layers, click a marker
> and then zoom. The popup stays put. I was not sure what to use instead ofr
> "wfslayer".
>
> /asle
>
> 2009/6/11 Ivan Grcic <igrcic at gmail.com>
>>
>> Hi Asle, this migh help also, especiall if you are using some strategy
>> like BBOX with wfs layer:
>>
>> wfsLayer.events.register('loadstart', this, function (evt){
>>        if(selectedFeature && selectedFeature.popup){
>>            selectControls.unselect(PARAMS.selectedFeature);
>>           //selectControls.unselectAll();  <= this might also work
>>        }
>> }
>>
>> i was banging my head with this one for some time, then i figured out
>> that features are NOT being unselected before they are removed from
>> the layer (BBOX has changed => new features are fetched)
>>
>> that way the popup stays on map but that feature that the popup has
>> been opened on doesnt exist anymore, and there was no way to close the
>> popup.
>> registering loadstart event and unselecting feature there before the
>> strategy loads new features did the job!
>>
>> hope it helps someone,
>>
>> cheers
>>
>> On Tue, Jun 9, 2009 at 2:15 PM, Alexandre Dube<adube at mapgears.com> wrote:
>> > Hi,
>> >
>> >  Just put a break point on this line :
>> >            if (*feature.popup[]*= null){
>> >
>> >  Then, using the "script" tag and at the right the "watch" tab, you will
>> > then be able to see all variables and object currently available,
>> > including "this" (which should be your map object).
>> >
>> >  There's plenty of tutorials on the web that could help.  Just google
>> > "firebug how to use" for example.
>> >
>> > Best of luck,
>> >
>> > Alexandre
>> >
>> >
>> > Asle Benoni wrote:
>> >> 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
>> >>
>> >
>> >
>> > --
>> > Alexandre Dubé
>> > Mapgears
>> > www.mapgears.com
>> >
>> > _______________________________________________
>> > Users mailing list
>> > Users at openlayers.org
>> > http://openlayers.org/mailman/listinfo/users
>> >
>>
>>
>>
>> --
>> Ivan Grcic
>
>



-- 
Ivan Grcic



More information about the Users mailing list