Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Google Maps Unable to set scroll zoom off

I have been trying to set the zoom on scroll param to off, but having no luck in turing the feature off.

I am using react-google-maps component. Linked below.

https://github.com/sohilpandya/Bidlt/blob/master/src/js/components/builder/overview-google-map.js

Would appreciate it if someone can cast an eye on it and help me figure out where to put the zoomscroll to off.

like image 767
Sohil Pandya Avatar asked Mar 18 '16 17:03

Sohil Pandya


2 Answers

Solved it by putting the scrollwheel:false as an option for GoogleMap component as such

<GoogleMap options={{ scrollwheel: false}}>

like image 85
Sohil Pandya Avatar answered Oct 19 '22 18:10

Sohil Pandya


The best solution here is to set
<GoogleMap options={{ gestureHandling: 'none'}}>

If you also want to hide the +/- zoom buttons you can add an additional option <GoogleMap options={{ gestureHandling: 'none', disableDefaultUI: true}}>

Documentation for scrollwheel option: Note: This property is not recommended. To disable zooming using scrollwheel, you can use the gestureHandling property, and set it to either "cooperative" or "none"

https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.scrollwheel

like image 35
Razvan Dragos Avatar answered Oct 19 '22 17:10

Razvan Dragos