Interactive Mapping Blog

Mapping Solutions News

Archive for the ‘Silverlight’ Category

Calling all Silverlight Developers

Thursday, February 11th, 2010

Earthware is an entrepreneurial company specialising in developing online mapping solutions and websites using the latest technologies. Silverlight is proving to be the future direction of our company which is why we are looking for a developer with experience in this technology but with a hunger to learn more both here and in other technologies and to apply this throughout the planning, designing and development process. Other required skills include strong full life cycle Asp.net, C# and WCF, whilst experience with Ajax frameworks, XSLT / XML and unit testing is desirable.

 

If you fit this description and are interested in applying for the position please email your CV explaining how you meet our requirements and giving example projects/URLs to recruitment@earthware.co.uk.

 

All applicants must be eligible to work in the UK. No contact from agencies please.

BBC Show the “Art of the Possible” with Microsoft Bing Maps Silverlight SDK

Monday, February 1st, 2010

At the inaugural Bing Maps User group in the UK, Jim Lynn from the BBC was invited to present on a project that he led at the BBC to explore how Bing Maps Silverlight can be used.  I am not a techie but found this a fascinating exploration into how Silverlight is transforming the online mapping experience.  As a synopsis, Jim spent nearly twelve months on different aspects of this project.  First, he created and loaded Ordnance Survey map tiles into Bing Maps Silverlight to enable deep zoom Ordnance Survey mapping. He then explored how you can integrate geographical based data and information into the maps using examples such as David Dimbleby’s “How We Built Britain” showing the video playing as the marker moves along a path on the map as the video shows him driving down a road.

Jim also separated the Ordnance Survey names layer from the map layer to enable the map to be rotated whilst the names remain horizontal on the page (no mean feat) and embedded deep zoom photographs at their correct geographical locations which cluster to avoid overlapping as you change zoom levels. These embedded photographs can also be ‘flipped over’ to reveal information about the place on the back. He also showed (for a small part of Britain) how the BBC archive can be displayed on a Bing Map.

If you want to talk about how your data/information/business can be brought to life using Bing Maps Silverlight, please contact Earthware for a chat.

Bings Maps Launch Streetside, Enhanced Bird’s Eye and many more new features

Thursday, December 3rd, 2009

After months of biting their tongues, Bing have finally announced their latest additions to Bing Maps by releasing the beta version of Silverlight Bing Maps which features two new map modes (Streetside View and Enhanced Bird’s Eye) plus an Application Gallery and also Photosynth to name just a few.

The entire site is built in Silverlight (although the Bing Maps AJAX site is still available  if for some reason you don’t want to see the amazing new features). Features include:

Streetside: ground level, fully stitched together high res photographs giving a seamless 360 degree panorama.

Enhanced Bird’s Eye: In urban areas: Bing have used high resolution photography and stereo data to create 3D models of locations and placed them into the 2D interface of a webpage but with 3D aspect ratio from Silverlight 3. In non-urban areas: Bing have used their satellite imagery and aerial photos and re-projected the Earth to give a better perspective of the world.

Application Gallery: a catalogue of all the Bing Maps applications creating a simplified search and bookmarking function.

Photosynth: now fully integrated into the maps so you can fly in from space straight into your next door neighbours lounge(!) (but only if they have created a synth of course).

Simultaneous Multiple Searches: perform multiple searches within one map to discover all you can (tweets, blogs articles, local businesses, imagery etc)about a location without leaving the map.

Local Search Integration: Bing Local Search fully integrated into Bing Maps (the opposite has been available for a while).

Simplified Navigation: The navigation buttons have been moved to the bottom of the page and you can select Automatic (based on user feedback), Road, Aerial or Bird’s Eye or Streetside (our new friend ‘Blue Man’) views.

Integrated 1-Click Directions: if you know where you’re trying to get to, search for the location and select directions to get there approaching from the north, south, east or west.

Route Query Parsing: if you are planning to drive from, for example, Seattle to San Diego just enter “Seattle to San Diego” in the search box and get point to point driving directions.

Auto-Location Detection: when you load Bing Maps in Silverlight the site will automatically detect where you are located and centre the map to show your current position.

Weather: weather information has been embedded into the maps allowing you to view the latest weather conditions at your current location (using the auto-location detection) or for the location you are searching for.

Images: Bing Image Search has been integrated into Bing Maps giving you instant access to images of the location you are searching for.

Defined Regions Query Parsing: search for a neighbourhood within a city, for example, “San Diego Gaslamp,” and the map will centre on that neighbourhood and highlight the area on the map.

For a full list and description of the new features read Chris Pendleton’s blog or if you would rather watch a demo click here.

The Earthware team has been eagerly awaiting this latest offering from Bing Maps. The enhanced functionality is set to make displaying and searching for location based information much more simple. We know the Bing Maps team have been working very hard to develop this and we congratulate them on what they have achieved.

If you are interested in creating a map using Silverlight (or any other mapping API) to display your information then please drop us a line at info@earthware.co.uk.

Come and meet Earthware at upcoming Bing Maps developer events

Sunday, November 15th, 2009

We live in exciting times as Bing Maps developers, and these next few month look to continue to be exciting as we have two upcoming developer events to attend.

The first event is the Microsoft Bing Maps developer day on 25th November in Reading which you can register for here http://is.gd/4NFjv. Come and hear Earthware’s Brian Norman talk about our experience developing the Bing Maps World Tour application for Microsoft. Also speaking are the excellent Johannes Kebeck (Microsoft) and Ricky Brundrit (Infusion Development). If you haven’t had much time recently to keep up with the latest releases, especially the Silverlight control then it’s and event not to miss.

The second event is even more exciting for us as it has taken a long while for a UK Bing Maps developer community to emerge but it looks like we are there now. Put the evening of 13th January 2009 in you diary now as it will be the first meeting of the Bing Maps UK User Group! This will be an opportunity for us developers to really kick back and geek out on Bing Maps, with free beer and pizza to set the right mood. This is a community run event, the first meeting being sponsored by Microsoft, which we hope will inspire us continue to create great Bing Maps applications here in the UK. Register for the event here http://is.gd/4VpOs.

Come and meet Earthware at upcoming Bing Maps developer events

Sunday, November 15th, 2009

We live in exciting times as Bing Maps developers, and these next few month look to continue to be exciting as we have two upcoming developer events to attend.

The first event is the Microsoft Bing Maps developer day on 25th November in Reading which you can register for here http://is.gd/4NFjv. Come and hear Earthware’s Brian Norman talk about our experience developing the Bing Maps World Tour application for Microsoft. Also speaking are the excellent Johannes Kebeck (Microsoft) and Ricky Brundrit (Infusion Development). If you haven’t had much time recently to keep up with the latest releases, especially the Silverlight control then it’s and event not to miss.

The second event is even more exciting for us as it has taken a long while for a UK Bing Maps developer community to emerge but it looks like we are there now. Put the evening of 13th January 2009 in you diary now as it will be the first meeting of the Bing Maps UK User Group! This will be an opportunity for us developers to really kick back and geek out on Bing Maps, with free bear and pizza to set the right mood. This is a community run event, the first meeting being sponsored by Microsoft, which we hope will inspire us continue to create great Bing Maps applications here in the UK. Register for the event here http://is.gd/4VpOs.

Great Example of Using Overlays and Heat Maps in Microsoft Bing Maps

Thursday, October 22nd, 2009

At Earthware we are always on the lookout for Microsoft Bing Maps (formally Microsoft Virtual Earth) implementations that use mapping to display useful information in a really intuitive way.  We are especially keen to see overlays (or heat maps) being used in Bing Maps.
 
We came across a good example the other day that uses Bing Maps to plot crime statistics for the UK. Please take a look at http://maps.police.uk/.
 
Our view is that the interface is simple enough and we like the subtle use of a gun sight for showing you where the centre of the map is. If we had any suggestions it might be that the polygons can get a bit ropey at the lowest zoom levels and the use of shaded grey rather than two tones is not as visually differentiated as it could be. We might also suggest adding the ability to see crime statistics for neighbouring counties when you are close to a border.
 
However, great idea, nicely implemented - congratulations to those involved in the project.
 
As always, if you are reading this article and are interested in creating heat maps in any mapping API (Bing Maps, Silverlight, Google Maps, Multimap, MapPoint etc.) or just want to see how you could use interactive mapping to display your information then please drop me a line at neil@earthware.co.uk.

Bing Maps Silverlight control – top 10 wish list for release

Monday, June 22nd, 2009

UPDATED: As recommend by SoulSoltions in the comments I have marked each wish by whether it should be in the core control or in a separate toolkit (IMHO)

We have spent the last month working with the current Bing maps Silverlight CTP control (formally Virtual Earth) to create the new Bing Maps World Tour application which has been a really great experience. The current Silverlight control opens up a whole new world of possibilities when creating rich mapping solutions but as always we want MORE!

 

Here is our top 10 wish list for features and tweaks to be in the final map release in no particular order:

 

1.     Custom map view animations – include in core
Being able to quickly customise the speed and style of animation the map uses when navigating between map views would be great and allow developers and designers to add their own unique touch to their mapping projects.

 

2.     A basic pushpin & infobox control – include in toolkit


The Silverlight control team have deliberately left the creation of pushpins and popups to developers and designers as this gives us complete control and flexibility which is great and something missing from the current Ajax control. However, we can see some good reasons to have a basic pushpin and infobox offered by the final control release.

Firstly for new Silverlight developers coding a pushpin and infobox that works the same as the Ajax pushpin control is not a simple task so having a basic control they can style or build upon would allow people to get simple applications up and running faster.

Secondly for experienced developers being able to inherit from built-in controls will save a lot of repeated coding in different projects.

 

3.     Easy to style navigation controls – include in core
You can currently style the navigation controls, but getting access to this functionality is not straightforward (hopefully we will blog a tutorial on this soon). Being able to just apply a style or custom template as for normal Silverlight controls would be brilliant.

 

4.     Bird’s eye imagery – include in core


It goes without saying that Bird’s eye imagery is one of Bing maps greatest features, we hope it will make it into the first official release.

 

5.     Clustering – include in toolkit
Having a basic but extendable clustering solution would again help new and experienced developers quickly get applications online.

 

6.     Built in routing – include in toolkit
Although routing can currently be achieved quite simply using the examples from the interactive sdk, having this functionality built-in would save a lot of time and effort and again make it more open to new developers.

 

7.     Real time zoom level range data – include in core
The CTP release improves on the Ajax control by restricting zoom levels when the higher zoom levels are not available at a location. This is a great start but the data for this is not very detailed and you will still often get the dreaded camera icon appear.

Being able to get more detailed data, ideally in real time would be an excellent addition to the control ensuring we banish the camera icon forever! 

 

8.     Drawing controls – include in toolkit
Something that has often been requested for the ajax control is an officially supported set of drawing controls allowing polyline and polygon drawing as on bing.com. Having these available first in the Silverlight control would be great especially as it should be easier in Silverlight than it is in cross browser javascript. 

 

9.     KML / GeoRSS support – include in toolkit
The ability to quickly load a georss or kml file into the ajax control has been a massive help to new users and those of us wanting to quickly generate a map from existing content. Having this in the Silverlight control would encourage people to use the new control more as mashups would be quick to create.  

 

10.  Modular design
One issue with the ajax control has been that you need to download all the control code even if you don’t want to use all the features in your project. With the current Bing Maps Silverlight control dll coming in at 489kb it would be good to be able to optionally include features by having different dll’s for separate parts of the control. Another option would be to support assembly caching for the Silverlight map control similar to that in Silverlight 3 for the core framework dlls.

 

It was actually pretty difficult to come up with 10 sensible wishes as the current control has so many great features already. It would be great to see these all release but I have no doubt they are not all, if any, on the release list. Hopefully those that don’t make it might become part of the new direction that the codeplex project DeepEarth is taking, by creating a collection of reusable map controls in Silverlight.

 

We would love to hear comments about your own suggested features to see what the community as a whole want to see developed, so please add your comments below.

Earthware develops ‘Bing Maps World Tour’ for Microsoft

Monday, June 22nd, 2009

The Microsoft Bing Enterprise Mapping team approached Earthware two months ago, with an idea to communicate their monthly imagery releases to clients and partners in a more visually engaging format.

With each month’s imagery release potentially covering hundreds of updated locations worldwide the current system of publishing a simple list of all the locations was not demonstrating the full impact of each release. Microsoft was also keen to use their latest Bing Maps Silverlight control, to create a visually rich interactive mapping application which could be both a showcase for the monthly updates, and the possibilities that Silverlight and Bing maps can offer.

Microsoft were also keen to host the new application on the Windows Azure platform to show the flexibility of combining Azure services with the Bing Enterprise maps.

Windows Azure Development    Bing Maps     Microsoft Silverlight Development

Why Earthware?

Earthware already had extensive experience with Bing maps and the new Silverlight control after taking part in the closed beta program in early 2009. As part of this Earthware produced a Twitter map demo application which Microsoft demoed as part of the Bing Maps Silverlight control’s release publicity. The Twitter demo also used the Azure platform.

What did we deliver?

Bing Maps World Tour

  • A visually rich mapping application using Microsoft’s Bing Maps Silverlight Control and hosted on the Windows Azure platform.
     
  • A secure back office administration area to allow the Microsoft team to quickly, and easily, add and update monthly imagery release information.
     
  • A back end database built upon the Windows Azure table storage service.
     
  • The entire first release of the Bing Maps World Tour application was delivered in less than six weeks and in time for the challenging May 2009 imagery release deadline.
     

Try the finished Bing Maps World Tour application for yourself on the Bing Maps Website or read more about the application at the official Bing maps blog. You can also see the reaction of the developer community to the applications release on twitter.

If you are interested in Earthware helping you to create similar interactive animated mapping applications for your products please visit our interactive mapping consultancy page.

Add a bit of ‘Bing’ to your silverlight maps

Tuesday, June 2nd, 2009

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:

Virtual Earth Silverlight Minimap Tutorial

Saturday, March 21st, 2009

In this tutorial I’m going to show you how to create a simple styled minimap to use in your Virtual Earth Silverlight projects that looks exactly like the one we used in our Twittermap demo.

As those of you who have already tried the CTP control there is a lot of things we take for granted with the javascript control that required some work to achieve in Silverlight, the minimap is one of these but thankfully its really easy to create your own.

Getting Started

Assuming you already have your Silverlight development environment setup and have installed the Virtual Earth Silverlight CTP then start by creating a new Silverlight project, or use your existing project. First you need to add a reference to the Virtual Earth Silverlight control to your Silverlight project:

addingveslreference

Then add a simple Virtual Earth map control to your page.xaml as follows:

<UserControl x:Class="MinimapDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl">
    <Grid x:Name="LayoutRoot" Background="White">
        <m:Map Name="mymap" Mode="AerialWithLabels" >

        </m:Map>
    </Grid>
</UserControl>

Notice we have made our base usercontrol fill the entire screen by removing the width and height attributes, then we have added a xmlns namespace pointing to the virtual earth control and finally added a map to the xaml in ArialWithLabels mode.

Creating then MiniMap Control

Now we need to create the minimap itself, to do this we are going to create a new usercontrol in the Silverlight project. Right mouse click on the project file and click ”Add, New Item" then choose "Silverlight User Control". Name the control "MinMap.xaml".

Now we need to add a Virtual Earth map control to this new minimap control, in the same way we did for the main map in page.xaml:

<UserControl x:Class="MinimapDemo.MiniMap"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="208" Height="208"
    xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl">
    <Grid x:Name="LayoutRoot">
        <Canvas Canvas.ZIndex="99" Width="200" Height="200" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5">
            <m:Map Name="minimap" Width="200" Height="200" Mode="Road" LogoVisibility="Collapsed" ScaleVisibility="Collapsed" CopyrightVisibility="Collapsed" NavigationVisibility="Collapsed">
            </m:Map>
        </Canvas>
    </Grid>
</UserControl>

This time we have set the base usercontrol to have a width and height of 208 pixels and the map control to have a width and height of 200 pixels these are to set the size of our minimap control and you will see later why the map doesn’t quiet fill the usercontrol. We have added a Canvas control to the grid and used this to Horizontally align the map to the right and vertically align the map to the top when added to a parent control. It’s also added a margin of 5 pixels so that the minimap will be slightly in from the edge of the parent map we are going to add it to. One final thing the canvas provides is setting the z-index, this ensures the minimap control will always be on top of any of the parent maps controls.

We have also added quiet a few attributes to the map control, setting the map to Road style, hiding the logos, navigation, copyrights and scale bar.

Now its time to style the minimap a bit, something we didn’t have allot of flexibility over with the javascript api. We are going to make the map circular and add a opaque white border around the map:

<UserControl x:Class="MinimapDemo.MiniMap"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="208" Height="208"
    xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl">
    <Grid x:Name="LayoutRoot">
        <Canvas Canvas.ZIndex="99" Width="200" Height="200" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5">
            <m:Map Name="minimap" Width="200" Height="200" Mode="Road" LogoVisibility="Collapsed" ScaleVisibility="Collapsed" CopyrightVisibility="Collapsed" NavigationVisibility="Collapsed">
                <m:Map.Clip>
                    <EllipseGeometry RadiusX="94" RadiusY="94" Center="100,100" />
                </m:Map.Clip>
            </m:Map>
            <Ellipse Width="200" Height="200" Stroke="White" StrokeThickness="6" Opacity="0.7" />
        </Canvas>
    </Grid>
</UserControl>

We have added 2 things this time, a clipping path to the map control by adding an Ellipse to the Map.Clip tag and adding another Ellipse as a sibling control with a white line (stroke) 6 pixels wide and slightly opaque. In the xaml preview the control now looks like this:

minimapxamlpreview

There is one final touch to add to the minimap control before we start working on integrating it with the main map and that is adding a centre marker to the minimap.

<UserControl x:Class="MinimapDemo.MiniMap"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="208" Height="208"
    xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl">
    <Grid x:Name="LayoutRoot">
        <Canvas Canvas.ZIndex="99" Width="200" Height="200" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5">
            <m:Map Name="minimap" Width="200" Height="200" Mode="Road" LogoVisibility="Collapsed" ScaleVisibility="Collapsed" CopyrightVisibility="Collapsed" NavigationVisibility="Collapsed">
                <m:Map.Clip>
                    <EllipseGeometry RadiusX="94" RadiusY="94" Center="100,100" />
                </m:Map.Clip>
            </m:Map>
            <Ellipse Width="200" Height="200" Stroke="White" StrokeThickness="6" Opacity="0.7" />
            <Ellipse Height="6" Width="6" Fill="#FFFF0000" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="98,98,0,0" />
        </Canvas>
    </Grid>
</UserControl>

We have done this by adding another Ellipse as a sibling to the map control that is 6 pixels wide and high, coloured red and positioned in the middle of our control using a combination of alignments and margins.

Now lets get the maps working together!

Combining Both Maps

To make the minimap actually work as a minimap we need to add a few events and two properties to the minimap’s map control. The events will stop the minimap reacting to a users mouse events, we add these to both the xaml and the code behind:

XAML


<m:Map Name="minimap" Width="200" Height="200" Mode="Road" LogoVisibility="Collapsed" ScaleVisibility="Collapsed" CopyrightVisibility="Collapsed" NavigationVisibility="Collapsed" MouseClick="Map_MouseClick" MouseWheel="Map_MouseWheel" MousePan="Map_MousePan">


Codebehind

namespace MinimapDemo
{
    public partial class MiniMap : UserControl
    {
        public MiniMap()
        {
            InitializeComponent();
        }

        private void Map_MouseClick(object sender, Microsoft.VirtualEarth.MapControl.MapMouseEventArgs e)
        {
            e.Handled = true;//dont want minimap to be interactive
        }

        private void Map_MouseWheel(object sender, Microsoft.VirtualEarth.MapControl.MapMouseWheelEventArgs e)
        {
            e.Handled = true;//dont want minimap to be interactive
        }

        private void Map_MousePan(object sender, Microsoft.VirtualEarth.MapControl.MapMouseDragEventArgs e)
        {
            e.Handled = true;//dont want minimap to be interactive
        }
    }
}

The 3 mouse events have set the event as handled so the default events the map control has for these will not be executed. Now onto the two properties we need to add, these are simply adding a property to control where the minimap is centred geographically and one for its zoomlevel.

        public Location Center
        {
            get
            {
                return minimap.Center;
            }
            set
            {
                minimap.Center = value;
            }
        }

        public double ZoomLevel
        {
            get
            {
                return minimap.ZoomLevel;
            }
            set
            {
                minimap.ZoomLevel = value;
            }
        }

You will need to add "using Microsoft.VirtualEarth.MapControl;" to the code behind before it recognises the Location class. Now before we go any further build the project so that we have the minimap control available.

Now lets actually add the new minimap control to the main page.xaml:

<UserControl x:Class="MinimapDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl"
    xmlns:mm="clr-namespace:MinimapDemo">
    <Grid x:Name="LayoutRoot" Background="White">
        <m:Map Name="mymap" Mode="AerialWithLabels">
            <m:Map.Children>
                <mm:MiniMap Name="minimap" HorizontalAlignment="Right" VerticalAlignment="Top" />
            </m:Map.Children>
        </m:Map>
    </Grid>
</UserControl>

We have added an xml namespace at the top pointing to the current project, this will allow us to use the minimap control. Then we have added the minimap to the Map.Children tag and positioned it in the top right of the map.

We are almost there now, there is just one final thing to do. We need to hook up the main maps TargetViewChanged event so that it moves the minimap to a new location and sets the zoom level appropriately. We do this by adding the event to the xaml and then adding something to the code behind to change the minimap:

XAML

<m:Map Name="mymap" Mode="AerialWithLabels" TargetViewChanged="Map_TargetViewChanged">

Codebehind


        private void Map_TargetViewChanged(object sender, Microsoft.VirtualEarth.MapControl.MapEventArgs e)
        {
            MiniMap minimap = (MiniMap)mymap.FindName("minimap");//get the minimap child control
            minimap.Center = mymap.Center;//change center of mini map
            minimap.ZoomLevel = (mymap.ZoomLevel - 5) < 0 ? 1 : (mymap.ZoomLevel - 5);//make sure minimap is at least zoomlevel 1
        }

In the codebehind first we are finding the minimap control by name from its parent map control (for some reason I have to do it this way where as previously I have just been able to call minimap directly??). Then we are setting the minimap’s Center property to be the same as the main map and finally setting the ZoomLevel property to be 5 less than the main map, unless the main map is zoomed out to level 5 or below itself. That’s if we’re done you should now be able to run the project and load up your working minimap!

minimapfinished

What else can we do?

You can tweak things for your own requirements like the zoom level offset and the size of the minimap pretty easily. You can also make a more exciting centrepoint marker for the minimap using some simple animation but that’s outside the scope of this tutorial. I look forward to seeing some great projects over the next few weeks so get busy building!

UPDATE: John Darling pointed out the minimap in this code seems to be one step behind the main map, after having a look we shoudl be using the zoomlevel and centerpoint of the TargetView (view that the map is currently animating to) rather than the current maps state. Therefore the updated event handler for Map_TargetViewChanged should be:

   1: private void Map_TargetViewChanged(object sender, Microsoft.VirtualEarth.MapControl.MapEventArgs e)
   2: {
   3:     
   4:     MiniMap minimap = (MiniMap)mymap.FindName("minimap");//get the minimap child control
   5:     minimap.Center = mymap.TargetView.Center;//change center of mini map
   6:     minimap.ZoomLevel = (mymap.TargetView.ZoomLevel - 5) < 0 ? 1 : (mymap.TargetView.ZoomLevel - 5);//make sure minimap is at least zoomlevel 1
   7: }