diff --git a/lib/OpenLayers/Layer/Text.js b/lib/OpenLayers/Layer/Text.js index 2fe8eb05ac..c010648bf0 100644 --- a/lib/OpenLayers/Layer/Text.js +++ b/lib/OpenLayers/Layer/Text.js @@ -31,6 +31,14 @@ OpenLayers.Layer.Text.prototype = { method: 'get', onComplete:this.parseData.bind(this) } ); }, + /** + * + */ + destroy: function() { + this.clearFeatures(); + this.features = null; + OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments); + }, /** * @param {?} ajaxRequest @@ -133,6 +141,18 @@ OpenLayers.Layer.Text.prototype = Event.stop(evt); }, + /** + * + */ + clearFeatures: function() { + if (this.features != null) { + while(this.features.length > 0) { + var feature = this.features[0]; + this.features.remove(feature); + feature.destroy(); + } + } + }, /** @final @type String */ CLASS_NAME: "OpenLayers.Text"