[JS] แก้ปัญหา Google Map ใหญ่ ๆ โดน Mouse Scroll แล้วซูม

เดี๋ยวนี้เป็นเทรนด์แบบ One Page Design ที่ต้องมี Google Map ใหญ่ ๆ ในเว็บไซต์ ซึ่งถ้าใช้ Trackpad หรือเม้าส์กลาง Scroll ตอนเม้าส์เราวางอยู่บน Google Map ใหญ่ จะเป็นการซูมโดยอัตโนมัติ

สรุปว่า Google Map V3 API มี Option ออกมาให้แล้วแก้แบบง่าย ๆ แล้ว คือ

options = $.extend({
    scrollwheel: false,
    navigationControl: false,
    mapTypeControl: false,
    scaleControl: false,
    draggable: false,
    mapTypeId: google.maps.MapTypeId.ROADMAP
}, options);

ตอนที่เราเรียกใช้ Google Map ผ่าน JavaScript ก็กำหนด scrollwheel: false เข้าไป เท่านี้เม้าส์ Scroll ก็ไม่มีผลแล้ว 😀

 

Reference: http://stackoverflow.com/questions/2330197/how-to-disable-mouse-scroll-wheel-scaling-with-google-maps-api


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *