MapDotNet UX Help

Microsoft Bing Maps™ make an ideal base map to display beneath your data.  A TileLayer using a BingMapsTileRequestor can be placed at start of your TileLayer collection to accomplish this.  Tile layers can be added either declaratively or in code.

Adding a Bing Map Tile Layer Declaratively

You must first declare the map itself.  The map declaration should include the address of the MapDotNet UX Web Service instance used.  You must also set the Map.TileProjection property and Map.MapModel properties.  Your tile layers will be nested within the map model.

Namespace declarations for Silverlight:


Namespace declarations for WPF:


Control markup:

<rim:Map MDNSAddress="">

        <Projections:SphericalMercatorTileProjection />


     	<!-- Tile layers go here. -->



See Add the RIM Control for more about the map declaration.

The declaration for any tile layer includes a Descriptor and a Requestor.  The Requestor for a Bing Maps tile layer is an instance of the BingMapsTileRequestor class.  The Descriptor should be one of the Bing Maps flags, such as "r" for roads or "a" for aerials.  The TileLayer can be assigned a Name to reference it in the code-behind.

<rim:TileLayer x:Name="BaseMapTileLayer" Descriptor="r">
        <Requestors:BingMapsTileRequestor />

This snippet is taken from the first example in our Interactive SDK, where you can also see how to declaratively data-bind a ComboBox to the Descriptor to change the map view without any code-behind.

The declarative approach is the preferred way to add tile layers.

Adding a Bing Map Tile Layer in Code

To add a Bing Maps™ tile layer as a base map to the RIM control perform the steps below after you have set up your RIM control. For more information on TileLayers go here.

WPF and Silverlight (c#)

// create an ITileRequestor implementation for Virtual Earth
var bingRequestor = new BingMapsTileRequestor();
var bingTileLayer = new TileLayer("myVELayerID", veRequestor);

// set your VE user access token - this is obtained through Microsoft's VETokenService
// this appends the VE token to the end of the request for Microsoft usage tracking
// if this is not set the request will still be made but such requests will be outside Microsoft's TOU (terms of use)

bingRequestor.VEToken = myToken;

// 1.0 fully opaque, 0.0 fully transparent
bingTileLayer.Opacity = 1.0;

// 'h' - hybrid, 'a' - aerial, 'r' - road
bingTileLayer.Descriptor = "h";

// alternately
// bingTileLayer.Descriptor = veRequestor.BuildDescriptor(BingMapTileRequestor.Descriptors.Hybrid);

// 500 mS tile fade-in time - omit this line for immediate display
bingTileLayer.FadeInDuration = new Duration(TimeSpan.FromSeconds(0.5));

// add your layer to the map

Note: in order for proxy connectors in Silverlight to access content routed through your application server, the proxy.ashx file must be present in your /clientbin folder on the server. See the sample applications for more information.