The OverlayManager for the Bing Maps Silverlight control now lets you define time to your overlays through the VisibleTimeRange property, which means that it will filter out any overlays who are marked with a time range outside the visible time range. (By default overlays are always visible.)
Adding time as a dimension to a map adds a lot of interesting opportunities for map applications. Displaying markers has always been the main focus, but with interactive web applications being considered as required it becomes still more difficult to view any kind of data outside of its temporal context. This is why I added the VisibleTimeRange property to the OverlayManager. This provides an easy way to ensure that the data displayed is not outdated or not in the future based on the viewing context, i.e. showing you what is considered active content for your view.
Before we go further I should mention that the OverlayManager now defines an attached property, which allows you to easily hook it on to your map directly in XAML, like so:
XAML
<UserControl x:Class="MapApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ve="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl"
xmlns:reimers="clr-namespace:Reimers.Silverlight.VirtualEarth;assembly=Reimers.Silverlight">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<ve:Map x:Name="map"
LogoVisibility="Collapsed"
NavigationVisibility="Collapsed"
ScaleVisibility="Collapsed">
<reimers:OverlayManager.Manager>
<reimers:OverlayManager />
</reimers:OverlayManager.Manager>
</ve:Map>
</Grid>
</UserControl>
Once that's done you are ready to work with time enabled overlays. The Reimers.Silverlight.TimeRange class (actually struct) defines a From and To property that lets you define a time range. The OverlayManager defines a TimeRangeProperty as an attached property, which means that you can attach it to any DependencyObject. Like so:
C#
FrameworkElement marker = new Ellipse();
DateTime markerFromDate = new DateTime(2009, 7, 1);
DateTime markerToDate = markerFromDate.AddMonths(1);
OverlayManager.SetTimeRange(marker, new TimeRange(markerFromDate, markerToDate));
If you attach a time range to an overlay the OverlayManager will read it and determine if the overlay is to be displayed depending on what time range is defined as visible for the moment.
To make it easy to define a time range in the UI, the Reimers.Silverlight assembly also comes with a TimeRangeSlider control (templatable, of course), which is basically a slider, except that it has two markers, high and low, that you can drag.
XAML
<UserControl x:Class="MapApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ve="clr-namespace:Microsoft.VirtualEarth.MapControl;assembly=Microsoft.VirtualEarth.MapControl"
xmlns:local="clr-namespace:VirtualMap.Controls"
xmlns:controls="clr-namespace:Reimers.Silverlight.Controls;assembly=Reimers.Silverlight"
xmlns:reimers="clr-namespace:Reimers.Silverlight.VirtualEarth;assembly=Reimers.Silverlight">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<ve:Map x:Name="map"
ScaleVisibility="Collapsed"
NavigationVisibility="Collapsed"
LogoVisibility="Collapsed">
<reimers:OverlayManager.Manager>
<reimers:OverlayManager />
</reimers:OverlayManager.Manager>
</ve:Map>
<controls:TimeRangeSlider x:Name="timeBar"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
SelectedRangeChanged="timeBar_SelectedRangeChanged" />
</Grid>
</UserControl>
C#
private void timeBar_SelectedRangeChanged(object sender, EventArgs e)
{
OverlayManager.GetManager(map).VisibleTimeRange = timeBar.SelectedRange;
}
As you can see in the code above, when the SelectedRange property is updated (fx, by dragging the range slider) the map's visible time range updates as well and the markers are redrawn.
An example app could for example be an Elvis spotting map, which plots the locations where Elvis has been spotted. Without a visible time range property for the map the application would either have to display all Elvis sightings (I'm sure there are quite a few), or have to make multiple lookups every time the user changed the current view range, which means that you would lose the ability to analyze based on surrounding data.
Another more practical application would be to hook it up to your Google Analytics account. Then you can display visitor locations with time awareness and quickly change between different time periods for comparison (so many ideas, so little time).
Remember, this is still in beta, so some feature may not be fully implemented. For example, databinding is still in development. But please don't let this stop you trying it out and sending some feedback.