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) {
            } else {
            this.layer.selectedFeature = (!sameMarkerClicked) ? this :

code by Christopher Schmidt : http://www.mail-archive.com/[email protected]/msg03869.html

2 Answers 2


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


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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