Bing Maps 8 Initialization Options

Bing Maps version 8 is scheduled to be released sometime this year. I’ve been looking at a pre-release version to get a feel for what’s new. Today I looked at map initialization options — different ways for loading a map into a Web page.


First, there are two loading modes, synchronous and asynchronous. To load asynchronously, you put a script tag that points to the Bing Maps 8 library, in the HTML head section. Then, you write a GetMap() JavaScript function and put a onload=”GetMap();” attribute in the HTML body tag.

To load asynchronously, you put a script tag with an attribute like this:

src='(URL)?callback=GetMap' async defer

at the end of the HTML body section (and the HTML body tag needs no onload attribute).

A program-defined function GetMap() looks quite the same as version 7 code. For example:

var map = null;

function GetMap()
  var options = {
   credentials: "AmUck2V2b_etc_jSCm",
   center: new Microsoft.Maps.Location(45.50, -122.50),
   mapTypeId: Microsoft.Maps.MapTypeId.road,
   zoom: 8,
   enableClickableLogo: false,
   showCopyright: false

  var loc = document.getElementById("mapDiv");
  map = new Microsoft.Maps.Map(loc, options); 

For some reason, I could not get the map height and width options to work. I’m not sure if they’ve been deprecated or the calling mechanism changed somehow. I’ll be glad when the documentation is released.


This entry was posted in Miscellaneous. Bookmark the permalink.