[GIS] OpenLayers layer text popup override code not work

openlayers-2

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

Best Answer

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