[OpenLayers-Users] Clustering and addFeatures method

Jacolin Yves yjacolin at free.fr
Thu Oct 16 11:54:48 EDT 2008


Le Thursday 16 October 2008 17:31:19 Eric Lemoine, vous avez écrit :
> Hi Yves. I don't see anything wrong with what you're doing. So you're
> saying you are adding two features (far from each other), and
> nevertheless see only one of the two on the map, right? Could you cook
> up a small example so that we can reproduce the problem. Eric
>
> 2008/10/16, Jacolin Yves <yjacolin at free.fr>:
> > Hello,
> >
> > I am trying to set up a cluster strategy for one of my vector layer. I
> > add this code to my existing code:
> >   var vector = new OpenLayers.Layer.Vector(name,
> >                   {
> >                      strategies: [
> >                         new OpenLayers.Strategy.Cluster({distance:20})
> >                       ]
> >                   }
> >                 );
> > Before this, the code was " var vector = new
> > OpenLayers.Layer.Vector(name);"
> >
> > I fill my vectorLayers later, reading a postgis result with:
> >
> > var feature = wktParser.read(_tmp[1]);
> > [..]
> > vectorLayer.addFeatures([ feature ]);
> >
> > I get only one feature (instead of 2) for all the zoom level. I tried to
> > change the distance option above, but nothing append. If I check the DOM,
> > nothing show me that there are more than 1 feature in this layer.
> >
> > Where am I wrong?
> >
> > Y.
> > PS : the code is much more longer than here and is split in several
> > functions
> > so I can't show you all in once, I tried to put the most readable as
> > possible.
> > --
> > Yves Jacolin
> > ---
> > http://softlibre.gloobe.org
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users

Hi Eric,

More information. The two building are quiet close as they are in the same 
street. But for the zoom level I used I would like that they are displayed in 
two geometries. In a zoom of level 1 to 5 (about) I would like to display 
only one geometry.

Here a screenshot to explain: without cluster strategy, I get the two 
geometries, for this zoome level this is good. With the cluster strategy, I 
get the orange one only.
http://img80.imageshack.us/img80/4786/olclusterse5.png

Note: if I zoom out then I zoom in, the geometry display is the red one ^^

Regards,

Y.
-- 
Yves Jacolin
---
http://softlibre.gloobe.org



More information about the Users mailing list