react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

[Feat] Expose props mapping to `disableRotation()` on the touch-zoom-rotate handler

Open mz8i opened this issue 2 years ago • 3 comments

Target Use Case

Currently it's not possible to enable touch zoom but disable touch rotate.

The touch zoom+rotate handlers for both Maplibre and Mapbox expose a disableRotation() method, so that sort of granularity is allowed by the base libraries.

Proposal

There are different ways the API could look, but an example (that I believe was the case with older versions of this library) is: expose an additional touchRotate prop that, if false, will cause calling disableRotation() on the touch-zoom-rotate handler.

mz8i avatar Sep 14 '23 20:09 mz8i

Current workaround is to use a ref function:

const mapRefFn = useCallback((refObj) => {
  refObj?.getMap()?.touchZoomRotate?.disableRotation();
}, []);

return (<Map ref={mapRefFn} touchZoomRotate={true}>
   {/* ... */}
</Map>);

mz8i avatar Sep 14 '23 20:09 mz8i

I have also run into a need for this! Happy to take this on, if help is needed.

csdiehl avatar Oct 05 '23 22:10 csdiehl