[OpenLayers-Dev] zoom slow when overlay vector layer as marker

Ivan Grcic igrcic at gmail.com
Wed Mar 17 15:38:18 EDT 2010

Hi, im coping my previous answear to some similar question...

 I would say your solution depends on two things: level of
interactivity you want to achieve and browser limits.

Most important thing to have in your mind: Browser limit says don't
load more then (having IE in mind) -> 100-150 features!

Off course we would like to have the highest level of interactivity,
that is, to have all the features loaded - vector layer, so we can
have fast hover/click effects on features. But because of browser
limits that's not possible. So depending on your data, we can cope
with this with different solutions:

1) Use wms layer with GetFeature control
Like this all the feature show up, but you only get some info when you
click on it. Bad thing is that sometimes it takes some time to query
the features
(lower interactivity), so make sure you have fast response from your
server for this (spatial index data usually helps ;)
Use this for large scales of you layer

2) Use vector layers. Use this solutions when you are sure that you
wont be requesting lots of features at once (browser limits). Using
BBOX with Cluster strategy is not a bad solution. Use this for small
scales (small areas -> less features are requested)
One important note here: Cluster strategy that we have here is a
client solution, that means all the data has to be received before
they are clustered. Example: we have 5000 points. If we use cluster
strategy they will be visualized with, lets say, 100 points -> within
browser limits right? But what about the data transfer and expensive
calculations of clusters (every time we zoom in?) Conclusion: be
careful with  cluster strategy, don't use it if you have more then few
hundreds features (and use it together with BBOX strategy)

3) Develop server clustering - this should be the best solution I
think (most intereactive also) Let server process the data, and make
clusters for you, with some basic cluster info - like geometry, number
of features in cluster etc. Then you make vector layer out of it, and
implement lets say hover effect that get basic data, and on click you
make GetFeatureInfo request that gets the rest of the data.

The best example that works in similar way is maps.google.com with
Wikipedia & Photos layers, where you can see tons of images at once
without lots of stress on thebrowser.

On Tue, Mar 16, 2010 at 5:01 PM, Tim Schaub <tschaub at opengeo.org> wrote:
> dequan chen wrote:
>> hi all,
>> I overlay Vector Layer to the map to monitor vehicles. every 5 second,
>> update the location. I use vector layer as vehicle marker.
>> Vehicle.vehicleLayer = new OpenLayers.Layer.Vector("",
>>         {
>>             styleMap: new OpenLayers.StyleMap({
>>                 "default": {
>>                     externalGraphic: "img/v1.gif",
>>                     graphicWidth: 24,
>>                     graphicHeight: 12,
>>                     graphicYOffset: -5,
>>                     rotation: "${angle}",
>>                     label: "${vno}",
>>                     fontSize: "11px",
>>                     fontColor: "purple",
>>                     labelAlign: "${align}",
>>                     fontFamily: "Arial,Verdana",
>>                 }
>>             })
>>         });
>> the problem is, the vector layer contains almost 500 features stand for 500
>> vehicles. when i zoom the map, the browser can nearly not work. user should
>> wait 1 or 2 minutes or even more. but when i zoom the district that only
>> monitor dozens of vehicles, pan or zoom the map will be normal. In the
>> future, the vehicle number will reach to 1000.
>> Is there any solution to this problem ? It is very ergent to me. thanks.
> You'll get better performance if you avoid using rotation in a point
> symbolizer.  This is very handy for limited numbers of features, but can
> become a bottleneck for rendering large quantities of features.
> A workaround is to pre-rotate your graphics, and have the
> externalGraphic property set based on some feature attribute (e.g.
> `rotation / 10 | 0`).
> You could also likely increase performance by not labeling all of your
> features.  If you hope to eventually display 1000 vehicles, I doubt
> things will look nice with 1000 labels anyway.  Displaying vehicle
> information based on mouse events (mouseover, click) may scale better
> than labeling all features.
> Without profiling your application it's tough to get too much more
> specific about where you could improve performance.
> Tim
>> ------------------------------------------------------------------------
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
> --
> Tim Schaub
> OpenGeo - http://opengeo.org
> Expert service straight from the developers.
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

Ivan Grcic

More information about the Dev mailing list