So I am trying to limit the zoom using javascript with the Bing Map API. Now I have seen this question asked on here but the solutions are not exactly what I am looking for.

There is the ability to see the zoomRange by calling these:

```
map.getZoomRange().max;
map.getZoomRange().min;

```

What I want is to be able to set these. I can't seem to find anything in the MapOption object.

An example of what I want is at this site here: <http://www.suncadiaresort.com/interactive-resort-map> 

Now if you try zooming using their controls on the map there is a definite max and min zoom.

But the solution given here, [Restrict the min/max zoom on a Bing Map with v7 of the AJAX control?](https://stackoverflow.com/questions/4327665/restrict-the-min-max-zoom-on-a-bing-map-with-v7-of-the-ajax-control) does not make a definite max or min. It is checking to see if the user has scrolled past that point and then setting the zoom. This causes jittering and doesn't always catch. 

I really just want to be able to set a max zoom and min zoom so that the map can not be scrolled farther out(or in, if necessary) than what they have just like in the example site.

As for code I am using the second suggestion from the other question, but I will show it here too.

I call the function from an event handler:

```
Microsoft.Maps.Events.addHandler(map, 'targetviewchanged', restrictZoom(map, 12, 18, mapCenter));

```

Here is the function: 

```
function restrictZoom(map,min,max, mapCenter)
{
    Microsoft.Maps.Events.addHandler(map, 'targetviewchanged',function()
    {
        var targetZoom = map.getTargetZoom();
        var adjZoom = targetZoom;

        if(targetZoom > max)
        {

            adjZoom = max;  
        }
        else if(targetZoom < min)
        {
            adjZoom = min;  
        }

        if(targetZoom != adjZoom)
        {
            map.setView({center: mapCenter, zoom:adjZoom}); 
        }
   });
}

```