[OpenLayers-Users] Draw Box From Selected Features

Alexandre Dube adube at mapgears.com
Mon Jun 27 08:45:50 EDT 2011


Hi Richard,

   Using Firebug, try to watch VectoLayer.features to see if the feature 
gets correctly pushed.  I think it should since your code looks okay at 
first sight.  If it is, then it could simply be a styling issue.  Try 
removing the last argument when creating the feature to let the default 
style be used.

   If that doesn't help, try to put a break point in the 'addFeatures' 
method of OpenLayers/Feature/Vector.js to see what's going on.

HTH,

Alexandre


On 11-06-25 01:08 PM, Richard Barnes wrote:
> 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]);
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users


-- 
Alexandre Dubé
Mapgears
www.mapgears.com



More information about the Users mailing list