0

I want to disable an OpenLayer map's draw pan during activation of a DrawFeature Control. What I am trying to do so far, is overwriting the dragstart method of OpenLayers.Handler.Drag.prototype in the control's activate method and readjusting it in its deactivate method.

However, I am not happy with this since I would prefer to tinker around with the Drag Handler object directly - instead of its prototype - and besides, I am pretty sure there is a more elegant solution which I was not able to find so far.

1

You could deactivate/activate the control. It's usually created automatically as part of the default navigation control, so locate the control containing a dragPan object and call the appropriate method on that (deactivating the entire navigation control is also possible but would also prevent mouse or touch zoom).

map.controls.forEach(function(control) {
  if (control.dragPan) {
     control.dragPan.deactivate();
  }
});



map.controls.forEach(function(control) {
  if (control.dragPan) {
     control.dragPan.activate();
  }
});

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.