mapbox-gl-draw
mapbox-gl-draw copied to clipboard
Draw interferes dragPan.disable()
mapbox-gl-js version: 0.37 mapbox-gl-draw version: v0.17.4
Steps to Trigger Behavior
- Load map.
- Load Draw control
- 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
Hi,
Same problem here. Did you find a workaround ?
Thanks,
No, I never did - was hoping to hear from the folks who developed this to see if they had any insight?
Ah! I keep hoping to have time to really dive into this. Sorry.
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.
Thanks, appreciate you looking into it. Let me know if there's anything I can do on my end?
@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.
Any solution?
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');
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().
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.
any update?
any update
Hi there, is there any update on this? Mapbox-draw is still interfering with dragPan. Any chance you'll merge PR #1191 ?