Once you find the module you are interested in downloading be sure to check to see if it relies on any other plugins. Most, if not all modules should include both a sample of how to implement the module and documentation.

Adding a module to your web project

  1. Copy over the JavaScript file that contains the module to your project. Take note of any external resources it may use such as images or CSS style sheets. Copy over any external resources as needed, be sure to maintain the same folder hierarchy.
  2. Register the module being sure that the URL provided when registering points to where the JavaScript module is located in your web project.
  3. Load the module and include any necessary callback functionality. Often the callback function is where the module will be used for the first time.

Example of how to load in a plugin

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">
         var map;

         function myModuleLoaded()
            //call code that uses your module.

         function GetMap()
             // Initialize the map
             var options = {credentials: "Bing Maps Key"};
             map = new Microsoft.Maps.Map(document.getElementById('mapDiv'), options);

             // Register and load the arrow module
             Microsoft.Maps.registerModule("MyModule", "http://example.com/mymodule.js");
             Microsoft.Maps.loadModule("MyModule", { callback: myModuleLoaded });
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative;width:400px;height:400px;"></div>       

Last edited Aug 18, 2011 at 4:54 PM by rbrundritt, version 4


No comments yet.