Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have some problem with the popup code in OpenLayers, using Text layer (yes i know there already GML layer out there with text format, but i need to modify existing code), the problem was popup not removed when i open new popup (by clicking another marker)


OpenLayers.Feature.prototype.popupClass = OpenLayers.Popup.FramedCloud;

        OpenLayers.Layer.Text.prototype.markerClick = function(evt) {
            var sameMarkerClicked = (this == this.layer.selectedFeature);
            if (this.popup) {
                this.popup.toggle(); 
            } else {
                this.layer.map.addPopup(this.createPopup(true));
            }
            this.layer.selectedFeature = (!sameMarkerClicked) ? this :
null;
            OpenLayers.Event.stop(evt);        
        } 

code by Christopher Schmidt : http://www.mail-archive.com/users@openlayers.org/msg03869.html

share|improve this question

2 Answers 2

I've successfully used the functions from this post: http://lists.osgeo.org/pipermail/openlayers-users/2009-August/013002.html

share|improve this answer

As far as I know, in an OpenLayers map viewer showing a new popup window does not imply that other already present popup windows will automatically be closed (at least when I was working with OpenLayers, more that 1 year ago).

You can get such behaviour by (a) having a list of references to already open popup windows, (b) close all popups present in this list when opening a new popup window and (c) updating the list.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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