Sponsored Links

Overview of the Virtual Earth Silverlight Control CTP PDF Print E-mail
Written by Richard Marsden   
Monday, 18 May 2009 09:38

There was quite a bit of excitement at this year's MIX 09 when Microsoft announced their Virtual Earth Control for Silverlight. This is still at the Community Technology Preview (CTP) stage and should not be used for production code. It is intended as a preview for feedback - think of it as an early beta.

Silverlight has been receiving a lot of attention in the past year after the release of Silverlight 2 with support for .NET programming. The combination of XAML (Extensible Application Markup Language) and .NET programming in a browser environment allows the rapid development of visually rich and sophisticated applications. Perhaps more importantly, because .NET is compiled, the Silverlight Virtual Earth control is considerably more efficient than the existing Javascript control due to JavaScript relying on an interpreter.

 

For Silverlight development, you will need to use Visual Studio 2008 SP1 and the Silverlight SDK installed. It is probably also a good idea to familiarize yourself with Silverlight 2 development. I found Introducing Microsoft Silverlight 2.0, 2nd Edition a useful book to get up to speed on XAML and Silverlight 2 development.

The Virtual Earth Silverlight Map Control SDK CTP can be downloaded from Microsoft Connect, here.

You can quickly get started with the code examples provided by the Interactive SDK. This works in a similar manner as the popular interactive SDK that was created for the JavaScript control.

To use the Silverlight control, you will need to create a Silverlight application in Visual Studio. Add a reference to "Microsoft.VirtualEarth.MapControl.dll" in the Virtual Earth SDK's Libraries sub-directory. The default location is c:\Program Files\Microsoft Virtual Earth Silverlight Map Control\CTP\Libraries. You can now insert the control into your XAML. Here is a simple XAML application that uses the control:

ERROR [include_code_listing plugin]: File Not Found (/usr/www/users/winwaed/geowebguru/img/2009/ve_silverlight_simple.xaml)

 

Note that the parent UserControl element defines the 'm' namespace for Virtual Earth. The map is inserted using an m:Map element.

The Virtual Earth object can be manipulated in the same way as any other XAML object. For example the following code rotates and animates the control without the need for any C#:

ERROR [include_code_listing plugin]: File Not Found (/usr/www/users/winwaed/geowebguru/img/2009/ve_silverlight_spin.xaml)

 

Here is the working control (click the static image for a popup window):

Click to see the Cutty Sark Silverlight Virtual Earth Example

 

XAML video can be inserted as a scalable control on a map. There are examples of this in the interactive SDK. Although most examples use a rectangular video, you could clip the video to the outline of a geographic feature. For example a map of the world could show videos of prime ministers and presidents clipped to the outlines of their respective countries.

Another much talked about feature in the Silverlight control is Deep Zoom. Deep Zoom produces a continuous zoom experience. Ie. as you zoom in, Silverlight displays a continuous animated zoom from one tile level to the next. This will produce many more tile requests than the existing JavaScript control and Web Service, but Microsoft promise that the pricing for the commercial license will take this into account and that it will not cost more.

The following code demonstrates Deep Zoom, and some simple pushpin addition code:

ERROR [include_code_listing plugin]: File Not Found (/usr/www/users/winwaed/geowebguru/img/2009/ve_pinjump.cs)

 

And here is the matching XAML:

ERROR [include_code_listing plugin]: File Not Found (/usr/www/users/winwaed/geowebguru/img/2009/ve_pinjump.xaml)

 

The working application can be found here. The application marks a number of well known locations in the US, and every few seconds moves from one location to the next.

As you can see, the Silverlight control promises a lot of visually impressive abilities. The use of C# makes it easier to program, and results in code which is significantly more efficient. Will it eventually take over from the JavaScript control? Quite possibly, but this probably also depends on the wider acceptance of Silverlight on non-Windows platforms. JavaScript will continue to have wider support for the foreseeable future, but it will probably be too limiting for many applications.


Last Updated on Monday, 18 May 2009 11:53