Search code examples
bing-mapsbing-api

bing map v7 control buttons


I am using bing map in my web application using api-reference7

i i have left,right,up,down buttons and i want user when click on these buttons they should behave as buttons on the control buttons.


Solution

  • var NAVIG_MAP_LEFT=1;var NAVIG_MAP_RIGHT=2;var NAVIG_MAP_TOP=3;var NAVIG_MAP_BOTTOM=4;
        var NAVIG_MAP_STEP=100;    
    function navigateMap(n, step){
                var loc = bingMap.getCenter();
                var locToPx = bingMap.tryLocationToPixel(loc);
                switch(n){
                case NAVIG_MAP_LEFT: locToPx.x = locToPx.x-step; break;
                case NAVIG_MAP_RIGHT: locToPx.x = locToPx.x+step; break;
                case NAVIG_MAP_TOP: locToPx.y = locToPx.y+step; break;
                case NAVIG_MAP_BOTTOM: locToPx.y = locToPx.y-step; break;
                }
                loc = bingMap.tryPixelToLocation(locToPx);
                bingMap.setView({center: loc});
            }