Reimers.dk

.NET, AJAX and Google APIs brought together
Welcome to Reimers.dk Sign in | Join | Help
in Search

Jacob Reimers Weblog

Google Maps for Silverlight

The title is not exactly correct if you had expected the cool DeepZoom maps with Google's imagery. Now you know :-)

What I am talking is a Silverlight control to display map images from Google's Static Map API. This means that you can display map imagery in your Silverlight application, and because it's Silverlight, you can use it in your list boxes or whereever you want.

The StaticMap control supports all the features of the Static Map API v2, which means you can display overlays and many different image types. You can define all the properties directly in XAML or you can bind them to other values in your application.

So if you don't need all the flash of DeepZoom maps, but need to display some geographic data, then this is what you are looking for.

XAML

<UserControl x:Class="TestApp.MainPage"
                         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         xmlns:map="clr-namespace:Reimers.Silverlight.GoogleMap;assembly=Reimers.Silverlight"
                         xmlns:ve="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl">
<map:StaticMap Coordinates="51.477,0"
                  Width="400"
                  Height="400"
                  Zoom="10"
                  GoogleKey="Your Google Key"
                  MapType="Satellite">
        <map:StaticMap.Overlays>
            <map:StaticMarker MarkerColor="Yellow"
                    MarkerSize="Mid"
                    Point="51.477,0" />
                <map:StaticMarker MarkerColor="Brown"
                                MarkerSize="Mid"
                                Point="51.577,0.1" />
                <map:StaticPolyline LineColor="Green"
                                Width="5">
                        <map:StaticPolyline.Points>
                                <ve:Location Latitude="51.477"
                                                Longitude="0" />
                                <ve:Location Latitude="51.577"
                                                Longitude="0.1" />
                        </map:StaticPolyline.Points>
                </map:StaticPolyline>
        </map:StaticMap.Overlays>
</map:StaticMap>
</UserControl>

Currently it is available in the SVN trunk, but it will be included in the next release of the Reimers.Silverlight assembly.

Published 3. september 2009 20:04 by jjrdk

Comments

 

alpinerocket74 said:

Hello Jacob,

Thanks for this great work. Is there any way when I click the map, to get the associated coordinates? (like you did in the GoogleMaps.NET for ASP.NET)

Many thanks,

Emmanuel

september 27, 2009 20:39
 

jjrdk said:

There will be as soon as I port the code from the ASP.NET static map control :-)

september 27, 2009 20:43
Anonymous comments are disabled