mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

Draw interferes dragPan.disable()

Open rvratner opened this issue 7 years ago • 13 comments

mapbox-gl-js version: 0.37 mapbox-gl-draw version: v0.17.4

Steps to Trigger Behavior

  1. Load map.
  2. Load Draw control
  3. map.drapPan.disable()

Expected Behavior

User can't drag pan the map

Actual Behavior

Map is able to be dragpanned

If you comment out the var draw = new MapboxDraw({ displayControlsDefault: false, controls: { polygon: true, trash: true } }); You are able to disable dragPan as expected

rvratner avatar Jun 08 '17 21:06 rvratner

Hi,

Same problem here. Did you find a workaround ?

Thanks,

Elefantz avatar Jun 30 '17 07:06 Elefantz

No, I never did - was hoping to hear from the folks who developed this to see if they had any insight?

rvratner avatar Jun 30 '17 17:06 rvratner

Ah! I keep hoping to have time to really dive into this. Sorry.

mcwhittemore avatar Jun 30 '17 17:06 mcwhittemore

OK. I took a quick look. This bug is happening in simple_select and direct_select but not that drawing modes. This makes me guess that we're enabling dragPan as some part of these two modes. I don't have much time right now to dive in deeper, but maybe that bit of info can help others push on this a bit.

mcwhittemore avatar Jun 30 '17 18:06 mcwhittemore

Thanks, appreciate you looking into it. Let me know if there's anything I can do on my end?

rvratner avatar Aug 01 '17 17:08 rvratner

@rvratner - If you have time to debug this a bit and make a PR when you find a solution that would be great.

Here are the three places Draw calls dragPan.disable() in these two modes.

  • https://github.com/mapbox/mapbox-gl-draw/blob/master/src/modes/simple_select.js#L215
  • https://github.com/mapbox/mapbox-gl-draw/blob/master/src/modes/simple_select.js#L155
  • https://github.com/mapbox/mapbox-gl-draw/blob/master/src/modes/direct_select.js#L32

I'd work on this by starting the debug page and adding some logging to the modes.

mcwhittemore avatar Aug 02 '17 14:08 mcwhittemore

Any solution?

GadyTal avatar Sep 13 '18 16:09 GadyTal

In my case, this issue affected the draggable markers on my map, which prevents them from being dragged due to the fact that the dragPan option can't be disabled which is required for dragging markers. (see https://www.mapbox.com/mapbox-gl-js/example/drag-a-point/)

Workaround

On marker's 'mouseenter' event we should prepare the markers for drag by changing the draw mode to draw_polygon (which doesn't cause the error) - placeDraw.changeMode('draw_polygon');

then, on 'mouseleave' fired we change it back to simple_select. placeDraw.changeMode('simple_select');

GadyTal avatar Sep 20 '18 10:09 GadyTal

MyWorkaround

I solved this problem by modifying mapbox-gl-draw.js file. I searched for "dragPan.enable()" statement and delete it from mapbox-gl-draw.js file. If you dont want to delete it entirely, you can wrap "dragPan.enable()" in an if clause so you can check the mapboxgl interaction option and then call dragPan.enable().

amirhossein1414 avatar Dec 17 '19 17:12 amirhossein1414

This is still an issue. Is this looked being looked at? @kkaefer

I belive it should work if when setting dragPan.enable(), you only do this if dragPan is not previously disabled.

john-melin avatar Jul 06 '20 18:07 john-melin

any update?

wandongming avatar Apr 15 '21 03:04 wandongming

any update

whatoeat2night avatar May 18 '21 19:05 whatoeat2night

Hi there, is there any update on this? Mapbox-draw is still interfering with dragPan. Any chance you'll merge PR #1191 ?

IlariaCallegari avatar Dec 19 '23 12:12 IlariaCallegari