The JSON error that the other guys reported is unrelated to the bounds error you're asking about. That's simply a matter of doing a better existence test where you load json2.min.js. Change this code in your map page:
<!--[if lt IE 8]>
<script src="../Scripts/json2.min.js" type="text/javascript"></script>
<![endif]-->
to:
<script type="text/javascript">
if( ! window.JSON )
document.write( '<script type="text/javascript" src="../Scripts/json2.min.js"><\/script>' );
</script>
The problem with the bounds is more subtle, and it is indeed a bug in the SetMapBounds function.
When you execute this statement:
currentMapBounds = this.MapBounds;
currentMapBounds does not get a new *copy* of this.MapBounds, it gets a reference to the this.MapBounds object *itself*.
So, when you later execute this statement:
currentMapBounds.union(this.MapBounds);
the target of the union is not just currentMapBounds, you are really reaching back and modifying whatever 'this.MapBounds' you were using in the first statement - because that is the very same object as currentMapBounds.
So in your test case, when you check the second route and it does the union(), it's actually enlarging the bounds of the *first* route. That's why the first route's bounds remain enlarged when you come back to it after clearing all the checkboxes.
You could easily fix that by changing this bit of code:
if( currentMapBounds )
currentMapBounds.union( this.MapBounds );
else
currentMapBounds = this.MapBounds;
}
to:
if( ! currentMapBounds )
currentMapBounds = new google.maps.LatLngBounds();
currentMapBounds.union( this.MapBounds );
Now you always create a new LatLngBounds object to receive the union of any individual LatLngBounds objects.
-Mike