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