最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do you get an iframe with google maps embedded in it to enable zooming by scrolling the mouse wheel? - Stack Overflow

programmeradmin9浏览0评论

When scrolling the mouse wheel over the embedded google maps, it will say to use ctrl + scroll to zoom the map.

I learned about a gesturehandling=auto or gesturehandling=greedy command you can tack onto the end of the embed URL in the iframe src attribute. I tried this, and it didn't work.

Does anyone know if it is still possible to scroll an embedded google map with a mouse wheel? If so, how would one go about enabling scrolling the mouse to zoom over an embedded map without holding ctrl?

Here is the code that I tried, which is still asking me to hold ctrl to scroll my map. I have tried this in firefox and edge.

    <iframe 
    src="=!1m10!1m8!1m3!1d157781.7349802922!2d-76.99238135019627!3d38.87518482466329!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sus!4v1738621870539!5m2!1sen!2susgesturehandling=greedy"
    width="600" 
    height="450" 
    style="border:0;" 
    allowfullscreen="" 
    loading="lazy" 
    referrerpolicy="no-referrer-when-downgrade">
    </iframe>

When scrolling the mouse wheel over the embedded google maps, it will say to use ctrl + scroll to zoom the map.

I learned about a gesturehandling=auto or gesturehandling=greedy command you can tack onto the end of the embed URL in the iframe src attribute. I tried this, and it didn't work.

Does anyone know if it is still possible to scroll an embedded google map with a mouse wheel? If so, how would one go about enabling scrolling the mouse to zoom over an embedded map without holding ctrl?

Here is the code that I tried, which is still asking me to hold ctrl to scroll my map. I have tried this in firefox and edge.

    <iframe 
    src="https://www.google/maps/embed?pb=!1m10!1m8!1m3!1d157781.7349802922!2d-76.99238135019627!3d38.87518482466329!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sus!4v1738621870539!5m2!1sen!2susgesturehandling=greedy"
    width="600" 
    height="450" 
    style="border:0;" 
    allowfullscreen="" 
    loading="lazy" 
    referrerpolicy="no-referrer-when-downgrade">
    </iframe>
Share Improve this question asked Mar 18 at 5:51 jhcwjhcw 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

This is because in <iframe> embed, Google Maps defaults to gestureHandling : 'cooperative' which requires the user to hold down the Ctrl key while scrolling to zoom the map since the API cannot determine whether the page is scrollable.

To enable scrolling without holding the Ctrl key, you need to use the Google Maps JavaScript API instead of an <iframe> and set an option gestureHandling: "greedy";

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论