Adding Intellisense to Bing Maps V7 or Windows Store Apps

  • Click on the download tab ad download the Bing Maps V7 Intellisense file.
  • Unzip the file and copy the Microsoft.Maps-vsdoc.js file from the BMJS folder to your project.
  • At the top of all your JavaScript files that use Bing Maps add a reference the Microsoft.Maps-vsdoc.js file.
    •  /// <reference path="[insert_path]/Microsoft.Maps-vsdoc.js" />
  • Intellisense should now be available.

Tips

  • Do not add this as a script reference on your HTML page. This would end up overwriting the Bing Maps control when the page loads and would cause the map not to load and possibly throw errors.
  • The Bing Maps V7 and Windows Store JavaScript control are nearly identical. As such this intellisense library can be used with both API's.

Implemented Workarounds

Bing Maps V7 makes use of Anonymous objects for setting options and event handler arguments. These can not be easily documented using intellisense. The following describes some workarounds that have been implemented to provide some insight into these objects using intellisense.

  • Anonymous objects: These have been handled in a couple of different ways in this intellisense library. Every method/constructor that takes in an anonymous object has multiple signatures. The first one will list all the properties of the object and their types, the second signature will attempt to list one property, it’s type and description per line. This works good when the object doesn’t have a lot of properties, when it does then it may get cut off.  The third signature is a reference to a class that is a placeholder and exists under the AnonymousObject namespace. This is useful for when the object is returned from a method as intellisense will work on the returned object. For example, try something like this:

    var mapOptions = map.getOptions();
    mapOptions.disablePanning =
    true;
    map.setOptions(mapOptions);

  • Events: When using the addHandler method it takes the following parameters: Object to add event to, name of event, and callback function. For any class that has events all the supported events are listed in its description. There is also an AnonymousObject called EventCallback which has a list of all the different events and their target object. For example:

 

Last edited Aug 27, 2014 at 3:28 PM by rbrundritt, version 2

Comments

No comments yet.