[OpenLayers-Users] Deleting a Vector Layer - How?

Eric Lemoine eric.c2c at gmail.com
Tue Aug 12 17:34:43 EDT 2008


Bilge, removeLayer won't destroy the layer. However the opposite is
true: layer.destroy() does remove the layer from the map. So, in fact,
layer.destroy() should suffice. Eric

2008/8/12, Bilge Tutak <bilge.tutak at gmail.com>:
> Looks like you are trying to access a non-existing layer (the one you
> recently removed) with the 3rd and 4th line.
>     myLayer.vector.destroyFeatures();
>     myLayer.vector.destroy();
> My guess it first destroy everything and then remove the layer.
>
> On Tue, Aug 12, 2008 at 4:10 PM, Bill Thoen <bthoen at gisnet.com> wrote:
>> I need to get rid of a vector layer and all of its contents, but I'm not
>> sure of the syntax. When I try:
>>
>>  if (myLayer != null) {
>>    map.removeLayer( myLayer );
>>    myLayer.vector.destroyFeatures();
>>    myLayer.vector.destroy();
>> }
>>
>> it seems to die on  'myLayer.vector.destroyFeatures();' How should I do
>> this?
>>
>> - Bill Thoen
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list