cvalenzuela / Mappa

A canvas wrapper for Maps 🗺 🌍
https://mappa.js.org
359 stars 104 forks source link

Unbind map from mouse/touch events #24

Closed willgeary closed 5 years ago

willgeary commented 5 years ago

Thank you for this great library! I'm hoping to make something similar to the Mapox GL example titled "Create a draggable point":

https://www.mapbox.com/mapbox-gl-js/example/drag-a-point/

screen shot 2018-09-13 at 2 29 31 pm

Luckily there is a p5.js example that accomplishes something similar (https://p5js.org/examples/input-mouse-functions.html). HOWEVER! When I try implement this with Mappa.js, the following problem occurs: When I try to drag a point with my mouse, it moves the underlying map as well since the map is binded to mouse drags.

Is there a way to temporarily unbind the map from the mouse?

I.e. something like the below:

// Unbind mouse/touch events
map.off('mousemove', onMove);
map.off('touchmove', onMove);

Thank you very much!

willgeary commented 5 years ago

I figured out how to do this using Mapbox's disable() functions:

myMap.map.dragRotate.disable(); myMap.map.dragPan.disable(); myMap.map.scrollZoom.disable() myMap.map.touchZoomRotate.disable();

Closing this issue!