Map inside of a tabbed panel Sample

When the map is initially loaded, it does some calculations to determine its dimensions. If the map is in a hidden tab, it will have width and height of 0 which will result in the map not loading. It is also a best practice to delay the loading of the map until it's tab is displayed. This will result in Bing Maps transactions only being generated once the map is actually being viewed by the user, which can help reduce costs. It also reduces the resources used by the page until the map is needed.

If you want to further optimize this code you can also delay the loading of the Bing Maps API by lazy loading the map.