I'm using Bing Maps version 8. I was trying to find but couldn't understand if there's an event when the map is fully loaded.
The issue I have is I first create a map:
var theMap = new MM.Map(document.getElementById('divMap'), ...
Then at some point after I get data for my map, I call
theMap.setView({
bounds: MM.LocationRect.fromLocations(locations)
});
The problem is there's some kind of race condition, I noticed that this does not work well when the map is not fully loaded. When the "divMap" doesn't yet contain a map canvas rendered by bing maps, then the height of the map is 0 and setView function sets incorrect zoom.
However when the map is loaded fully and I later call the same line through console in Chrome, it works fine.
I suppose I should call setView when the map is fully loaded, but I couldn't find the event I can use for this. Any ideas?
EDIT:
I think the problem is with the height of the DIV. In your example, the DIV has static 400px height, while in my situation it is dynamic and before the map is loaded and canvas is rendered, then the div height is 0px, causing setView to work incorrectly. I was trying to debug bing source files in javascript and noticed that it is dependent on the height, so that's the problem.

The event when the canvas is ready would help in this situation. For now I'm thinking to add a setInterval to check regularly.