【问题标题】:detecting right mouse double click with Bing maps使用 Bing 地图检测鼠标右键双击
【发布时间】:2012-12-01 21:16:35
【问题描述】:

我在 Bing 地图 API v7 中没有看到会显示双击事件的事件。有没有办法做到这一点?假设没有我错过的原生支持,我想我将不得不编写自己的带有计时器的双击处理程序。

【问题讨论】:

    标签: bing-maps


    【解决方案1】:

    点击事件也有问题。事实上,正常的点击事件也会在双击事件期间触发。这就是为什么我必须实现我自己的双击处理程序。我的方法可以翻译成右键单击,因为我只使用单击事件,鼠标右键也可以使用。

    //Set up my Handler (of course every object can be the target)
    Microsoft.Maps.Events.addHandler(map, 'click', Click);
    //count variable, that counts the amount of clicks that belong together
    myClick=0;
    
    //A click fires this function
    function click (e)
    {
        //If it is the first click of a "series", than start the timeout after which the clicks are handled
        if (myClick == 0)
        {       
            //Target have to be buffered
            target= e;
            //accumulate the clicks for 200ms and react afterwards
            setTimeout("reaction(target)", 200);
        }
            //count the clicks
        myClick = myClick+1;
    }
    
    //At the end of timeout check how often a click has been performed and react
    function reaction(e)
    {
        if (myClick==1)
        {
            alert("Single Click!");
        }
        else (myClick==2)
        {
            alert("Double click!");
        }
            else (myClick==3)
            {
                    alert("Tripple click");
            }
        //reset ClickCount to zero for the next clicks
        myClick = 0;
    }
    

    此外,删除 Bing-Maps 的标准双击行为以进行放大可能会很有趣。这可以通过以下代码实现:

    Microsoft.Maps.Events.addHandler(map, 'dblclick', function(e){
          e.handled = true;
    });
    

    【讨论】:

      【解决方案2】:

      如果你只使用双击事件

      Microsoft.Maps.Events.addHandler(this.map, 'dblclick', functionHandler)
      

      应该解决问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-03-14
        • 1970-01-01
        • 1970-01-01
        • 2014-07-10
        • 1970-01-01
        • 2012-02-02
        • 1970-01-01
        相关资源
        最近更新 更多