Selecting one or more markers using a bounding box?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Selecting one or more markers using a bounding box?

Morescratch
Hi all, has anyone had experience selecting one or more markers using a bounding box or polygon drawn by the user? I would like users to be able to select multiple markers by drawing a polygon. Any pointers or hints would be appreciated.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Selecting one or more markers using a bounding box?

Steffen G
Use the spatial filter. Here a example:  

var f = selectedFeature;
var bounds = f.geometry.getBounds();

var oFilter = new OpenLayers.Filter.Spatial({
        type: OpenLayers.Filter.Spatial.BBOX,
        value: bounds,
        projection: "EPSG:900913" // my projection, maybe not your
});

yourlayer.filter = oFilter;
yourlayer.refresh({force: true});

There is also a possibility with a spatial filter based on a polygon, but I have not valid it.