[OpenLayers-Users] Draw Box From Selected Features

Richard Barnes barn0357 at umn.edu
Sat Jun 25 13:08:20 EDT 2011


I'm trying to draw a box on a clustered map which will surround every 
selected feature. I've got this right now, but it doesn't seem to be 
working (no box appears). Any help would be appreciated :-)

var bounds=null;
for(i in stations.selectedFeatures)
   for(x in stations.selectedFeatures[i].cluster)
     if(bounds==null)
       
bounds=stations.selectedFeatures[i].cluster[x].geometry.getBounds().clone();
     else
       
bounds.extend(stations.selectedFeatures[i].cluster[x].geometry.getBounds());

Fit_box=bounds.toGeometry().components[0];
Fix_box=new OpenLayers.Feature.Vector(Fit_box, null, {fillColor: "green"});
VectorLayer.addFeatures([Fit_box]);


More information about the Users mailing list