[OpenLayers-Users] removeFeatures vs. destroyFeatures behavior

Eric Lemoine eric.c2c at gmail.com
Fri Sep 26 00:49:52 EDT 2008


Hi.

Yes, something could probably be done for eraseFeatures and
removeFeatures. The thing is that removeFeatures triggers a
featureremoved event for each feature removed. What we could do is
introduce removeAllFeatures which will be documented as not triggering
featureremoved events. Feel free to create a ticket for this, and
propose a patch. Thanks. Eric

2008/9/25, BrainDrain <paulborodaev at gmail.com>:
>
> little working solution:
> OpenLayers.Layer.Vector.prototype.destroyFeatures=function(features,options){
>
>     var all=(features==undefined);
>     if(all){
>         features=this.features;
>     }else{
>         if (!(features instanceof Array)){
>             features=[features];
>         }
>     }
>     if(features){
>         features=features.slice();
>         this.removeFeatures(features, options);
>         for(var i=features.length-1;i>=0;i--){
>             features[i].destroy();
>         }
>     }
> };
> It's strange for me that methods like eraseFeatures/removeFeatures/... don't
> handles <all features> cases avoiding passes through each feature. What if
> just write something like that:
>  	this.selectedFeatures = [];			
>         this.features = [];
>         this.unrenderedFeatures = {}; etc.
>
>
> youknowho wrote:
>>
>> Hi Eric. Thank you for the response. From what you said my understanding
>> of
>> removeFeatures and destroyFeatures is correct, and this appears to be a
>> bug.
>> Using the code from my original post I verified this incorrect
>> destroyFeatures() behavior again today, and will file a bug ticket.
>>
>> Thanks,
>> Ian
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/removeFeatures-vs.-destroyFeatures-behavior-tp18599629p19678021.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list