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.


Is it possible to disable the featureselected event so the map can be dragged?


i found this FAQ http://trac.osgeo.org/openlayers/wiki/SelectFeatureControlMapDragIssues

It works.

  • Can you clarify your question? Are you saying you want to drag a feature, or drag the map regardless of whether a feature or the map is clicked on? – CHenderson Sep 5 '13 at 20:56
  • i want to drag the map. – Simon Sep 6 '13 at 5:12
  • Do you need the selectFeature control? if not, you can remove it from the map or deactivate it. – mfdev Sep 6 '13 at 9:46
  • A sample without selectFeature implementation is visible here : openlayers.org/dev/examples/behavior-fixed-http-gml.html – simo Sep 6 '13 at 10:07
  • i need the selectfeature control too. – Simon Sep 6 '13 at 19:35

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 capture featureselected events on the two different vector layers. Removing (or deactivating) the OpenLayers.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 to true - 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.

  • i try set map.fallThrough = true; but seem like not working. – Simon Sep 6 '13 at 20:16
  • map.fallThrough is different. You need to extend the featureselected event to set fallThrough to true. Then when your code to handle the featureselected event has completed the vent should fall through to the map. – CHenderson Sep 6 '13 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.