Selecting features intersecting with a line
One common action when working with features within a vector layer is its selection and, of course, OpenLayers has some feature selection controls.
The OpenLayers.Control.SelectFeature
control is specially useful as a selection control because the selection is made on the client side, that is, the selection is made through the features loaded in the browser. There is no request to a WFS server.
The OpenLayers.Control.SelectFeature
control can work in different ways. We can select a feature just by clicking on it or we can draw a box to select all the contained features.
In contrast, it does not allow the possibility to select features that intersect with a path.
In this recipe, we are going to see how we can extend the OpenLayers.Control.SelectFeature
control to allow select features for drawing a path.
How to do it...
Create an HTML5 file and add the OpenLayers library dependencies. Now, include the code for the new
OpenLayers.Control.SelectFeature...