如何禁用谷歌街景上的鼠标滚轮缩放?

发布于 2024-09-24 21:35:20 字数 480 浏览 8 评论 0原文

考虑以下示例代码: http://code.google.com/apis/maps /documentation/javascript/examples/streetview-simple.html

我可以在地图选项上执行 scrollwheel: false 来禁用鼠标滚轮缩放。该功能未在街景全景选项上实现。

在 Chrome 中,我可以安全地禁用街景上的鼠标滚轮缩放。

$('#pano *').bind('mousewheel', function(){
    return false;
});

然而这在其他地方不起作用。请帮助我让它在排名前 3-5 的浏览器中运行?

Consider the following example code:
http://code.google.com/apis/maps/documentation/javascript/examples/streetview-simple.html

I can do scrollwheel: false on a mapOptions to disable mouse wheel zoom. The feature is not implemented on the streetview panoramaOptions.

In Chrome, I can safely disable mouse wheel zoom on the streetview simply by.

$('#pano *').bind('mousewheel', function(){
    return false;
});

However this does not work in elsewhere. Please help me get it working in top 3-5 browsers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

半﹌身腐败 2024-10-01 21:35:20

现在有一个已确认的功能请求,涉及 Gmaps API 问题 http: //code.google.com/p/gmaps-api-issues/issues/detail?id=2557。我们希望谷歌的工程师在遇到更重要的错误时能够对此进行调查。我不想屏住呼吸,但我现在先把它停下来。

There is now a confirmed feature request with Gmaps API issues http://code.google.com/p/gmaps-api-issues/issues/detail?id=2557. Let's hope Google's engineers will look into it when they get trough more important bugs. I hate to hold my breath, but I'll park this for now.

囚你心 2024-10-01 21:35:20

根据 Subgurim.net 的说法,这是如何做到的;

  [powerscript -  other event]
CONSTANT integer WM_MOUSEWHEEL = 522
IF message.number = WM_MOUSEWHEEL AND & KeyDown (KeyControl!) THEN
   message.processed = TRUE
   RETURN 1
END IF

我知道您正在使用 Javascript,这是一个 VB 示例,但希望它能有所帮助。

According to Subgurim.net, this is how to do it;

  [powerscript -  other event]
CONSTANT integer WM_MOUSEWHEEL = 522
IF message.number = WM_MOUSEWHEEL AND & KeyDown (KeyControl!) THEN
   message.processed = TRUE
   RETURN 1
END IF

I realise that you are using Javascript, and this is a VB example, but hopefully it helps.

彼岸花似海 2024-10-01 21:35:20

我使用下面的代码来避免双击缩放 - 非常确定它可以适应滚轮缩放。 Zoom: 1 是我最喜欢的变焦阶段,但可以是任何东西。

$("#panorama").dblclick( function(){

   panorama.setPov(  {
      heading: panorama.getPov().heading,
      pitch: panorama.getPov().pitch, zoom: 1 
   });

});

I use the below code to avoid double click zoom - pretty sure it could be adapted to scroll wheel zoom. zoom: 1 being my preferred zoom stage here, but could be anything.

$("#panorama").dblclick( function(){

   panorama.setPov(  {
      heading: panorama.getPov().heading,
      pitch: panorama.getPov().pitch, zoom: 1 
   });

});
梦中楼上月下 2024-10-01 21:35:20

有一个简单的解决方法:通过在街景之前添加一个具有较高 z-index 的图层,您将阻止街景的缩放功能。

<div id="panorama" style="position: absolute;left:0; top: 0;height: 100%; width: 100%; z-index: -1;opacity: 1"></div>
<div id="layerBeforePanorama" style="position: absolute;left:0; top: 0;height: 100%; width: 100%; z-index: 0;opacity: 1"></div>

<script>
var panoOptions = {
    position: latlng,
    pov: {
        heading: 0,
        pitch: 0
    }
  };
var pano = new google.maps.StreetViewPanorama(document.getElementById('panorama'), panoOptions);
</script>

There is an easy workaround: by adding a layer before the streetview with a higher z-index, you will prevent the zooming function of the Streetview.

<div id="panorama" style="position: absolute;left:0; top: 0;height: 100%; width: 100%; z-index: -1;opacity: 1"></div>
<div id="layerBeforePanorama" style="position: absolute;left:0; top: 0;height: 100%; width: 100%; z-index: 0;opacity: 1"></div>

<script>
var panoOptions = {
    position: latlng,
    pov: {
        heading: 0,
        pitch: 0
    }
  };
var pano = new google.maps.StreetViewPanorama(document.getElementById('panorama'), panoOptions);
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文