Interactive Mapping Blog

Mapping Solutions News

Add a bit of ‘Bing’ to your silverlight maps

As you cannot have missed in the news recently Microsoft has re-branded its search offering to be called “Bing”. This means Virtual Earth is now called Bing Maps for Enterprise.

Yesterday Microsoft automatically updated the Ajax Virtual Earth control to use the new Bing logo and you may have wondered why the Silverlight map control was not also updated? The reason is that the logo is a resource in the Silverlight control assembly and is not pointing to an external file.

So does that mean we have to wait for a new release of the Bing Silverlight map control before the logo will get changed? Well yes and no, if you want it to be automatically changed you will have to wait for the next release but there is nothing stopping you changing it yourself now by following the steps below.

Step 1 – Getting your project setup

If you don’t already have a Silverlight project setup with the Bing silverlight maps (Virtual Earth) control working see Chris Pietschmann’s excellent getting started tutorial.

Step 2 – Getting the new logo

You can download the new Bing logo from the url below:

http://www.bing.com/maps/i/logo_powered_by.png

Save this to a folder in your Silverlight project (for example Images) and then in Visual Studio ensure you include the new image in your Silverlight project and set it to be “Content” so that it gets included in the Silverlight xap file.

1

Step 3 – Hiding the existing logo

You may be asking how we turn off the existing logo? Well luckily the current Silverlight control allows us to hide the logo using the “LogoVisbility” attribute. You can do this in the XAML code as follows:

   1: <UserControl x:Class="BingLogoDemo.Page"
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
   4:     xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl">
   5:     <Grid x:Name="LayoutRoot" Background="White">
   6:         <m:Map x:Name="mainmap" LogoVisibility="Collapsed">
   7:             
   8:         </m:Map>
   9:     </Grid>
  10: </UserControl>

 

Step 4 – Adding the new logo

Now we need to add the new Bing logo. This is done by adding an image control and setting its “Source” attribute to point to the new logo file we downloaded in step 2. With a little alignment and margins we can get the logo to be in the same position as the original one. Below is the XAML showing you how to do this.

   1: <UserControl x:Class="BingLogoDemo.Page"
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
   4:     xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl">
   5:     <Grid x:Name="LayoutRoot" Background="White">
   6:         <m:Map x:Name="mainmap" LogoVisibility="Collapsed">
   7:             
   8:         </m:Map>
   9:         <Image Source="/Images/logo_powered_by.png" Width="93" Height="29" Margin="7 0 0 25" VerticalAlignment="Bottom" HorizontalAlignment="Left"  />
  10:     </Grid>
  11: </UserControl>

 

2

That’s it your all done.

Summary

Hopefully this tutorial has shown you just how easy this is to update. We could of course have used the online image file as the source of the image control, rather than including the new file in our application, but that might cause issues in future if Microsoft change the name of the file, or resize it. You can download a sample project showing the new logo below:

Comments are closed.