Friday, 20 March 2009

Silverlight VirtualEarth Map Control - initial impressions

Microsoft was bound to deprecate all the work on silverlightearth.com (and others on DeepEarth) at some point :D - and they've finally released a CTP of their efforts.

The control can be downloaded from Microsoft Connect: Silverlight Map Control - you have to register and fill in a survey first but then you're good to go. There is also a Getting Started guide to help, you know, get started.

It's actually pretty simple:
  • Add Reference to Microsoft.VirtualEarth.MapControl

  • Add namespace xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl"

  • and Xaml <m:Map x:Name="viewMap"/>

  • sprinkle a bit of C# (unnecessary, but why not)
    viewMap.View = new Microsoft.VirtualEarth.MapControl.MapViewSpecification(new Location(40.7199, -74.0030), 12.0000); //New York

and you've got a map!


Details

The control doesn't like being hosted on the filesystem (good old WebClient and ClientAccessPolicy restrictions I suppose) so when creating your first test project, remember to hook up a WebApplication as well...



otherwise you'll get the same error as the design surface does
Map loaded in unsupported URI scheme. Please reload page in http scheme.

but a WebApplication with an automatically created TestPage works just fine



Naturally I then wanted to apply it to something useful, so you can give this New York Marathon (2006) visualizer a go... in case it isn't obvious, it's showing how far behind the winner I was (and how far behind me Lance was :)
New York Marathon with Microsoft Virtual Earth Silverlight Control
I've blocked panning/zooming on it for now (until I figure out how to keep the animations and course in sync), but that is a bona-fide Microsoft Virtual Earth Silverlight Control (CTP) in there!
UPDATE [22-Mar]: I've updated the example so that dragging/panning works BUT zooming is still broken. I think I've copied the iSDK Add scalable element example exactly (but their Rectangle scales and my content doesn't). Weird...

The change was to move the 'animation canvas' inside the Map, like this:
<m:Map.Children>
<m:MapLayer>
<Canvas
m:MapLayer.MapRectangle="40.8325608405556,-74.1015908473376,40.5722860972124,-73.843755459154"
m:MapLayer.MapPositionMethod="Rectangle"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">


That didn't take long at all - so initial impressions are good. The map controls are very smooth and the basic stuff is intuitive to program around. In addition to the links above, you will want to play with the Interactive SDK and keep the SDK CHM handy until sample code starts appearing in the wild...

I wonder what the release date and go-live licensing details are???

6 comments:

  1. Cool, can you hook up another datasource like a WMS?

    ReplyDelete
  2. Check out the interactive SDK to get an idea of the API... I'm sure the various WMS providers could easily leverage the control to extend their existing services.

    This tutorial on adding custom map imagery and this one on using other tile layers (like OpenStreetMap) prove that it is extensible...

    ReplyDelete
  3. Hi Craig,

    Firstly great work on the race stuff. I have been working on some simular stuff that works with GPS Devices and you have got me out of a couple of head scratching moments!

    Have you tryed to migrate this stuff to the new Bing Maps release?

    The animations seen to freeze after teh first few seconds unless you manually move the map during the animation.

    Any Ideas?

    Mike

    ReplyDelete
  4. Hi Mike,

    I'm having the same problem - should never have upgraded!! Did you find a solution by any chance?

    Thanks,
    John

    ReplyDelete
    Replies
    1. Hi sir,
      You got any solution:

      "I did the changes under out-of-browser application and it is working fine i.e project is not opening under any browser, but now i want that project to be shown under browser.
      I reverted the changes, but now it is showing an error(i.e map is now visible(rest project is visisble)...and the error it is showing is "map loaded in unsupported uri scheme, please reload page in http scheme"."

      plz help and mail me at my id

      Delete
  5. Hi Craig,

    do you think it's possible to develope a similiar project using the WPF Bing Maps Control(Beta)?

    Thanks,
    Moritz

    ReplyDelete