[OpenLayers-Users] Vector layer popup doesn't close after layer refresh

Adrian Popa adrian_gh.popa at romtelecom.ro
Tue Jul 14 05:01:41 EDT 2009


I managed to close my active popups before doing the refresh.
Here's what I did on my example:

function updateMarkers(){
    //see if we have an active marker opened
    var openMarker = null;
    if(markers.selectedFeatures.length == 1){
        //save the marker 
details                                               
        openMarker = markers.selectedFeatures[0].attributes['description'];
        //close this 
popup                                                     
        map.removePopup(document.getElementById("chicken"));               
        
markers.selectedFeatures[0].popup.destroy();                           
        delete 
markers.selectedFeatures[0].popup;                              
        select.unselectAll();
    }

    //do the refresh
    markers.refresh({force: true});
}

Now, after the refresh is done, I would like to open again the popup. I 
would prefer to generate a click event at the coordinates stored in 
/openMarker/ and let the click handler deal with popup creation. The 
idea is that after refresh I might not get the popup at those 
coordinates, so the click event would not do anything...

Any ideas how I trigger a click at some specific coordinates? Or if 
that's not possible - how can I find a marker (in the markers.features 
array) which has my coordinates without going through the whole array?

Thanks,
Adrian

Adrian Popa wrote:
> Hi everyone,
>
> I'd like your help with a javascript problem.
> I want to draw markers from a script that generates KML output and I 
> have follows the sundials example: 
> http://openlayers.org/dev/examples/sundials-spherical-mercator.html
> However, if I want to refresh the KML layer and I have an open popup, 
> the popup div will no longer close after the layer refresh. You can see 
> this problem for yourselves in the above example, by clicking on a 
> sundial and then issuing the command (in firebug): 
> map.layers[2].refresh({force:true});
> This will cause the browser to re-get the KML data for the layer - and 
> the open popup will no longer respond to commands.
>
> My question is - how can I close the popup and re-open it after refresh? 
> I understand that I will need to write some code for that to work - but 
> I would like to know if I can send click events so that the usual 
> functions will do what they need to do. Any help is appreciated.
>
> Regards,
> Adrian
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>   


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090714/f1ff9da3/attachment.html


More information about the Users mailing list