How to temporaily block map zoom using Bing Maps API?

假装没事ソ 提交于 2019-12-25 03:15:57

问题


I am using Bing Maps API and I have to temporaily block zoom. Plese tell me how to do that using Java Script? I relize that I have to block some key controls and remove + / - buttons from default Bing Map controls.

Edit; To hide controlls I can use VEMap.HideDashboard Method. But how to block response for some keys? Do I have to overload some methods?


回答1:


You could override the events on map like this:

var bloc_zoom = false;
var bloc_pan = false;


function PaintMap()
{
    var VEMap = new VEMap(MapDivId);
    VEMap.AttachEvent("ondoubleclick", block_zoom);
    VEMap.AttachEvent("onkeydown", block_zoom);
    VEMap.AttachEvent("onmousedown", block_pan);
    VEMap.AttachEvent("onmousewheel", block_zoom);
}

function block_zoom(e)
{
     if(block_zoom)
     {
         return true ;
     }
}

function block_pan(e)
{
     if(block_pan)
     {
         return true ;
     }
}

Just turn on the flag when you want to block sum and/or Pan



来源:https://stackoverflow.com/questions/3136180/how-to-temporaily-block-map-zoom-using-bing-maps-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!