[OpenLayers-Users] remove a layer by name

Mr. Puneet Kishor punk.kish at gmail.com
Sun Sep 25 09:10:23 EDT 2011


On Sep 25, 2011, at 3:06 AM, Andreas Hocevar wrote:

> Hi,
> 
> for drawing the same vector layer with a different filter, you should use
> the Filter strategy.


Sorry, I used the wrong term, thereby misleading you with your answer. The simplest way to describe what I meant was: it is the same layer but with different data. I have daily sensor readings. Each day's readings are ~ 3000. I need to draw a day's reading, then when the user requests a different day, draw another day's reading, and so on. 

One thing I am thinking of doing -- at the full world zoom, draw WMS layers. The images generate instantly on the server side. Then, when the user zooms in a couple of clicks, flip to vector features with a BBOX strategy, or even throttle the number of features retrieved from the server by selecting features from the database for the current bbox.

> 
> 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



More information about the Users mailing list