none
How to restrict the zoom level RRS feed

  • Question

  •  

    hi all

     

    In my case i want to restrict the zoom level of the map . Virtual earth map has a zoom level between 1 and 19 . But in my application i want max Zoom level as 16 .Even if i  click the Zoom in button in dashboard the map should not zoom in further .the map should zoom in only upto 16 .

     

     

    Can any one help me in these

    • Moved by Ricky_Brundritt Saturday, March 10, 2012 11:52 AM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, May 6, 2008 9:25 AM

Answers

  • You will have to attach an event to the map to catch the onendzoom event. You will then have to handle this event. Here is some smaple code


    var map = new VEMap('mymap');

    map.LoadMap();

    map.AttachEvent('onendzoom', handleZoom);


    function handleZoom(e)

    {

    if(e!=null)
    {
    if(e.zoomLevel>16)
    {
    map.SetZoomLevel(16);
    return true;
    }

    }



    Tuesday, May 6, 2008 5:31 PM

All replies

  • You will have to attach an event to the map to catch the onendzoom event. You will then have to handle this event. Here is some smaple code


    var map = new VEMap('mymap');

    map.LoadMap();

    map.AttachEvent('onendzoom', handleZoom);


    function handleZoom(e)

    {

    if(e!=null)
    {
    if(e.zoomLevel>16)
    {
    map.SetZoomLevel(16);
    return true;
    }

    }



    Tuesday, May 6, 2008 5:31 PM
  • Thanks Richard,

     

    But the above code give bounce back effect. Could u please suggest some other solution which avoid that effect.

    Tuesday, May 13, 2008 6:36 AM
  • Currently there is no workaround to get rid of bouncing effect when trying to limit zoom.

    Thursday, May 15, 2008 1:02 PM
  • Is this still valid?  Is there still no workaround to get rid of the bouncing effect when trying to limit zoom (out or in)?
    Wednesday, November 9, 2011 6:19 PM