[OpenLayers-Users] remove a layer by name
Andreas Hocevar
ahocevar at opengeo.org
Sun Sep 25 04:06:09 EDT 2011
Hi,
for drawing the same vector layer with a different filter, you should use
the Filter strategy.
Andreas.
On Sep 24, 2011 10:58 PM, "Mr. Puneet Kishor" <punk.kish at gmail.com> wrote:
> I would like to remove a layer by name. The only method I see for removing
layer seems to take a layer object, which implies something like so
>
> var lyr_list = map.getLayersByName(name);
>
> Why does the above return a list? Under what use case would one have more
than one layer by the same name? In any case, I have all layers with unique
names, so the list would always have only one element.
>
> map.removeLayer(lyr_list[0]);
>
> The above works, but is there a more efficient or better way?
>
> A related question -- I am drawing 3 or 4 vector (line and point) layers
first, and then another vector layer with about 3000 points. Then, I want to
redraw this last layer, again with 3000 points, same data, different filter.
Since the user might want to bring back the first version of it, would it be
advisable to not remove the layer but to just turn its visibility off, and
draw a completely different layer? Would there be a performance hit?
>
> Finally, to build on the above -- I am trying to balance between drawing
images really fast on the server (WMS), but having limited interactivity in
the browser, vs. drawing vector layers in the browser, providing
interactivity, but potentially hurting performance. Right now I am not sure
of the bottlenecks (is there a way to profile the code?). The layers seem to
take a while coming, and then they draw instantly. Don't know if OL waits to
display the layer until after all the features have been rendered. For now,
I have approx 4-6 MB of data coming down the pipe for approximately half a
dozen layers. Just trying to gauge the limits without indulging in too much
premature optimization.
>
> Thanks,
>
> Puneet._______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110925/3471a077/attachment.html
More information about the Users
mailing list