[OpenLayers-Commits] r2971 - trunk/openlayers/lib/OpenLayers/Feature

commits at openlayers.org commits at openlayers.org
Mon Apr 2 07:19:34 EDT 2007


Author: crschmidt
Date: 2007-04-02 07:19:32 -0400 (Mon, 02 Apr 2007)
New Revision: 2971

Modified:
   trunk/openlayers/lib/OpenLayers/Feature/Vector.js
Log:
If a vector feature has a layer and it is destroyed, remove the feature from
the layer, and reset the layer to null.


Modified: trunk/openlayers/lib/OpenLayers/Feature/Vector.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Feature/Vector.js	2007-04-02 11:02:09 UTC (rev 2970)
+++ trunk/openlayers/lib/OpenLayers/Feature/Vector.js	2007-04-02 11:19:32 UTC (rev 2971)
@@ -58,6 +58,11 @@
      * 
      */
     destroy: function() {
+        if (this.layer) {
+            this.layer.removeFeatures(this);
+            this.layer = null;
+        }
+            
         this.geometry = null;
         OpenLayers.Feature.prototype.destroy.apply(this, arguments);
     },



More information about the Commits mailing list