user1642523
user1642523

Reputation: 381

Can't drag a map when clicking on a feature in a vector layer

I've got an OpenLayers map with a tile layer and Vector layer. The Vector layer has got an OpenLayers.Control.SelectFeature which is used to display a tooltip when the mouse hovers over a feature. Unfortunately this seems to prevent the map being moved if a feature is clicked and dragged.

Looking at the OpenLayers code, the SelectFeature just throws the click away because hover is set to true. Is there a way of passing the click event on to the map so that it can be moved?

I'm pretty sure the SelectFeature is the cause of the problem, since when I comment it out, drag works as expected.

Can anyone help?

Upvotes: 4

Views: 2545

Answers (2)

Rayiez
Rayiez

Reputation: 1599

Select feature

selectFeatureControl = new OpenLayers.Control.SelectFeature(layer,{
   onSelect: onFeatureSelect, 
   onUnselect: onFeatureUnselect
});

You can add this code to make it draggable when clicking on feature and dragging

if (typeof(selectFeatureControl.handlers) != "undefined") { // OL 2.7
    selectFeatureControl.handlers.feature.stopDown = false;
} else if (typeof(selectFeatureControl.handler) != "undefined") { // OL < 2.7
    selectFeatureControl.handler.stopDown = false; 
    selectFeatureControl.handler.stopUp = false; 
}

Upvotes: 0

winsent
winsent

Reputation: 486

Do not quite understand the problem, but maybe this will help:

selectControl.handlers.feature.stopDown = false;

Upvotes: 12

Related Questions