Thanks everyone for this bug report and patch suggestions. I have codified this in the OL trac:<br>
<a href="http://trac.openlayers.org/ticket/761">http://trac.openlayers.org/ticket/761</a><br>
<br>
<br><br><div><span class="gmail_quote">On 5/30/07, <b class="gmail_sendername">Mike Quentel</b> <<a href="mailto:mikequentel@yahoo.com">mikequentel@yahoo.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Also, add the following to OpenLayers.Layer.Vector:<br><br> destroySelectedFeatures: function () {<br> for (var i = (this.selectedFeatures.length - 1); i >= 0; i--) {<br> var selectedFeature = this.selectedFeatures
[i];<br> this.selectedFeatures
= OpenLayers.Util.removeItem(this.selectedFeatures, selectedFeature);<br> this.renderer.eraseGeometry(selectedFeature.geometry);<br> }<br> },<br><br>Mike Quentel<br><br>----- Original Message ----<br>
From: Mike Quentel <<a href="mailto:mikequentel@yahoo.com">mikequentel@yahoo.com</a>><br>To: Roger Kunkel <<a href="mailto:rakunkel@ucdavis.edu">rakunkel@ucdavis.edu</a>><br>Cc: <a href="mailto:users@openlayers.org">
users@openlayers.org</a><br>Sent: Wednesday, 30 May, 2007 5:22:48 PM<br>Subject: Re: [OpenLayers-Users] how to cleanly remove a vector layer<br><br>This might be of help to you...<br><br>OpenLayers.Control.EraseFeatures =
OpenLayers.Class.create();<br>OpenLayers.Control.EraseFeatures.prototype =<br> OpenLayers.Class.inherit( OpenLayers.Control, {<br> /** @type OpenLayers.Control.TYPES */<br> type: OpenLayers.Control.TYPE_BUTTON,<br>
trigger: function () {<br> if (this.map) {<br> var map = this.map;<br> for(i = 0; i < map.layers.length; i++) {<br> var currentLayer = map.layers[i];<br> if (currentLayer.isVector
) {<br> if (currentLayer.selectedFeatures.length > 0) {<br> currentLayer.destroySelectedFeatures();<br> } else {<br> currentLayer.destroyFeatures();<br> } //if (currentLayer.selectedFeatures..
.<br> } //if (currentLayer.isVector...<br> } // for (i = 0...<br> } //if (this.map...<br> },<br>/** @final @type String */<br>CLASS_NAME: "OpenLayers.Control.EraseFeatures"<br>});<br><br>
<br>Mike Quentel<br><br>----- Original Message ----<br>From: Roger Kunkel <<a href="mailto:rakunkel@ucdavis.edu">rakunkel@ucdavis.edu</a>><br>To: Christopher Schmidt <<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com
</a>><br>Cc: <a href="mailto:users@openlayers.org">users@openlayers.org</a><br>Sent: Wednesday, 30 May, 2007 3:35:07 PM<br>Subject: Re: [OpenLayers-Users] how to cleanly remove a vector layer<br><br>Thanks for your reply.
<br>I was using the removeFeatures incorrectly.<br><br><br>On May 30, 2007, at 1:53 PM, Christopher Schmidt wrote:<br><br>> On Wed, May 30, 2007 at 01:36:41PM -0700, Roger Kunkel wrote:<br>>><br>>> I'm having trouble using and then removing a vector layer.
<br>>> removeFeatures() - produces errors saying that the feature is not<br>>> defined when feature.geometry is referenced.<br>><br>> map.layers[1].removeFeatures(map.layers[1].features); works for me on
<br>> <a href="http://openlayers.org/dev/examples/vector-features.html">http://openlayers.org/dev/examples/vector-features.html</a> .<br>><br>>> calling destroy on the layer causes continuous mouse event errors
<br>>> - it seems that the getFeatureFromEvent method keeps getting called<br>>> even though I've destroyed the layer.<br>><br>> Yep. That's a bug. The only piece of advice I have for that is to not
<br>> destroy a layer if you have selectefatures handler on it :) I'll<br>> file it<br>> as a bug.<br>><br>> Regards,<br>> --<br>> Christopher Schmidt<br>> MetaCarta<br><br>Roger Kunkel<br>CERES Program
<br>Dept. of Land Air & Water Resources<br>UC Davis<br><a href="mailto:rakunkel@ucdavis.edu">rakunkel@ucdavis.edu</a><br><br><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@openlayers.org">
Users@openlayers.org</a><br><a href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</a><br><br><br><br><br><br> ___________________________________________________________<br>
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it<br>now.<br><a href="http://uk.answers.yahoo.com/">http://uk.answers.yahoo.com/</a><br><br><br><br><br><br> ___________________________________________________________
<br>Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for<br>your free account today <a href="http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html">http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html
</a><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br><a href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users
</a><br></blockquote></div><br>