[OpenLayers-Users] recenter on a vector layer with Cluster strategy on

Christopher Schmidt crschmidt at metacarta.com
Thu Dec 11 07:45:50 EST 2008


On Thu, Dec 11, 2008 at 10:16:44AM +0100, Didrik Pinte wrote:
> On Thu, 2008-12-11 at 08:39 +0100, Didrik Pinte wrote:
> > > 
> > > getDataExtent only works against the features currently in the layer --
> > > it isn'at aware of the 'subfeatures' inside the clusters. 
> > 
> > Ok, that explains the problem but the clusters have a data extent that
> > should approximately match the one of all the features, no ?
> 
> I have investigated a bit further. The Cluster strategy hides the
> clustered feature inside the cluster but the cluster is a feature inside
> the original layer. Thus, getDataExtent should get back with a bounding
> box around all the clusters and other features of the layer. In my case,
> the bounding box is just wrong, correctly centered but zoom is much too
> close, subsequently you see no data ;-)

When you call getDataExtent, presumably your map has no zoom yet. Since
the map has no size, it is as if you are zoomed out to the whole world
-- and at the whole world resolution, all o the points likely collapse
to one point. since they collapse to one point, your extent matches that
one point -- and you zoom in 'too far'.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list