When trying to drag the map, if the user clicks on a vector feature the featureselected
event is triggered and the map dragging does not happen. Please try to drag the map starting from any feature in the example below.
http://openlayers.org/dev/examples/select-feature-multilayer.html
Is it possible to disable the featureselected
event so the map can be dragged?
Solution
i found this FAQ http://trac.osgeo.org/openlayers/wiki/SelectFeatureControlMapDragIssues
It works.
Best Answer
The example you provided specifically demonstrates the ability to select features from different layers. In order to do this it includes an
OpenLayers.Control.SelectFeature
that is setup to capturefeatureselected
events on the two different vector layers. Removing (or deactivating) theOpenLayers.Control.SelectFeature
control will revert to default behaviour, that is to say the feature does not capture the mouse event and instead the map does, allowing it to be dragged.The example given by simo does not include the
OpenLayers.Control.SelectFeature
control and therefore demonstrates the map can dragged regardless of whether a feature or the underlying map is clicked on.If you need the ability to select the feature as well as being able to drag the map when a feature is initially clicked then you will need to look at extending the event so that
fallThrough
is set totrue
- which allows the event to fall through after it has been handled. This might then allow the map to pick up the click and drag event. I've not tried that so don't know if it would work.