[Users] Cluster's Extent

Alexandre Dube adube at mapgears.com
Wed Feb 17 14:24:36 CET 2010


Hi Luca,

You could create a very basic control that only has Handler.Feature 
that, on click on a cluster, do the following :

onClick = function(evt) {
var feature = (event.geometry) ? event : event.feature;
var bounds = new OpenLayers.Bounds(0,0,0,0);

// if the feature has not cluster, no need to do anything
if(!feature.cluster) {
return;
}

for(var i=0; i<feature.cluster.length; i++) {
bounds.extend(feature.cluster[i]);
}

yourMapObject.zoomToExtent(bounds);
}

You could use a SelectFeature control if you wanted for the "click" 
detection on your features.

Hope this helps,

Alexandre

Luca Casagrande wrote:
> Hello folks,
> I submitted this question on the OpenLayer's mailing list but I have
> got no answer, so I'll propose it to you hoping to find a solution:
> I'm using the cluster strategy for improving visualization of points from a WFS.
> Now I'm trying to figure out how to zoom to the extent of a cluster
> when you click on a point. Anybody has any ideas on how to create this
> function?
>
> Thank you!
>
> Luca
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com



More information about the Users mailing list