I have a relatively new found love for Silverlight, and when I got the chance to create a demo with Silverlight and Bing Maps I got very excited. The application gets objects from an existing Web Service. The objects contains meta data and coordinates in the format SWEREF 99. On silverlight.net there are information on how to get started with Silverlight. In addition, this is what you need to do to get started with Silverlight and Bing Maps:
This basic example is a foundation to a lot of fun, but the first challenge for me was the coordinate transformation, which is about as tricky as it sounds. The objects contains coordinates in plain SWEREF 99 format while Bing Maps uses decimal WGS 84 format.
Luckliy I found an excellent .NET library, MightyLittleGeodesy by Björn Sållarp, which allows me to transform the coordinates between a wide range of formats.
- Download and install Bing Maps Silverlight Control SDK.
- Create an account at Bing Maps Account Center to be able to create Bing Maps Keys.
<UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:bing="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl" mc:Ignorable="d"> <Grid x:Name="LayoutRoot"> <bing:Map CredentialsProvider="[BingMapCredentials]" Mode="Road" ZoomLevel="5" Center="61.71816218644379, 17.33600065112114"> <bing:Pushpin Location="59.331959746778026, 18.062450140714645" /> </bing:Map> </Grid> </UserControl>
This basic example is a foundation to a lot of fun, but the first challenge for me was the coordinate transformation, which is about as tricky as it sounds. The objects contains coordinates in plain SWEREF 99 format while Bing Maps uses decimal WGS 84 format.
Luckliy I found an excellent .NET library, MightyLittleGeodesy by Björn Sållarp, which allows me to transform the coordinates between a wide range of formats.
Comments
Post a Comment