Migrating from Bing Maps Silverlight CTP to Production version

With the official release of the Bing Maps Silverlight control there has been some changes from the CTP version. This article will address the required changes needed to migrate from the CTP version to the production version.

The first change is that the control now requires Silverlight 3. So if you are still using Silverlight 2 you will have to upgrade. You can get the required files to upgrade to Silverlight 3 here: http://silverlight.net/getstarted/

With the production version being released you are now required to authenticate the map. In the CTP version Microsoft took care of the authentication. The Silverlight control does not use tokens like the AJAX control; you can now use an application key. This removes the need to retrieve a client token when you load your map which means faster loading times. To get a key you first need an account. You can get an account here: https://www.bingmapsportal.com. After creating an account you can sign in using your Windows Live ID. Once signed in you can create up to 5 keys by clicking on the Create or view keys on the left side panel. To create a new key, enter the name of your application and the URL which corresponds to the website where the key will be used. Then click the Create key button. Once the key is created you can copy it and use it in your code. There are two ways to add this application id to your code. The first is to set the ApplicationId property of an ApplicationIdCredentialsProvider object and then use this object to set the CredentialsProvider property of the MapBase object. Alternatively you can add the application key to the XAML like so:

<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
Width="1024" Height="768">
       <Grid x:Name="LayoutRoot" Background="White">
             <m:Map x:Name="myMap" CredentialsProvider="Your key" Mode="Road"/>
      </Grid>
</UserControl>

You will need to update your Virtual Earth map control assembly reference. The new assemblies have been renamed as well. You will need to replace Microsoft.VirtualEarth.MapControl.dll with both Microsoft.Maps.MapControl.dll and Microsoft.Maps.MapControl.Common.dll.

With the change in assemblies the namespaces have also changed. Here is a mapping of the new namespaces:

Old Namespace

New Namespace

Microsoft.VirtualEarth.MapControl

Microsoft.Maps.MapControl

Microsoft.VirtualEarth.MapControl.Core

Microsoft.Maps.MapControl.Core

Microsoft.VirtualEarth.MapControl.Design

Microsoft.Maps.MapControl.Design

Microsoft.VirtualEarth.MapControl.Navigation

Microsoft.Maps.MapControl.Navigation

Microsoft.VirtualEarth.MapControl.Overlays

Microsoft.Maps.MapControl.Overlays

The following classes and properties have been removed or modified:

Old class

New class

AerialWithLabelsMode class

Removed. Use the Labels property of the AerialMode class to display labels.

INavigationBarCommand interface

Removed

MapBase class

Many members have changed. Use the Children property to add and remove child elements.

MapLayer class

Many members have changed. This class now inherits from MapLayerBase. Use the Children property to add and remove child elements.

MapMode class

Many members have changed.

MapViewSpecification class

Removed. Use the SetView method to set the map view. You can also use the map view properties Center, ZoomLevel, Heading, and Pitch.

MapViewSpecificationConverter class

Removed.

PositionMethod enumeration

Removed. Use the PositionOrigin struct instead.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s