Reputation: 474
I've created a WPF application to show the districts of Berlin with MapPolygon
s. Inside the <m:Map>
tag I created 12 times a MapItemsControl
to show the different districts. Here is the code for one:
<m:MapItemsControl ItemsSource="{Binding dMitte}">
<m:MapItemsControl.Style>
<Style TargetType="{x:Type m:MapItemsControl}">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=MitteVisibility, Path=IsChecked}" Value="True">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
</m:MapItemsControl.Style>
<m:MapItemsControl.ItemTemplate>
<DataTemplate>
<!-- ReSharper disable once Xaml.BindingWithContextNotResolved -->
<m:MapPolygon Fill="Red" Stroke="Black" StrokeThickness="2" Opacity="0.2" Locations="{Binding Path=Locations}"/>
</DataTemplate>
</m:MapItemsControl.ItemTemplate>
</m:MapItemsControl>
Every ItemsSource
has a property with a LocationCollection
where lots of Location
s are stored to draw the correct polygons.
Everything works fine. The only problem is, that dragging the map is pretty slow and laggy. The only thing I could think of to test the performance was the built in Performance Analysis tool from Visual Studio. That gave me this result:
Function Name Inclusive Samples Exclusive Samples Inclusive Samples % Exclusive Samples % Module Name
Microsoft.Maps.MapExtras.BitmapImageRequestQueue.DownloadThreadStart() 1 0 100,00 0,00 Microsoft.Maps.MapControl.WPF.dll
--Microsoft.Maps.MapExtras.BitmapImageRequestQueue.DownloadThreadStart() 1 0 100,00 0,00 Microsoft.Maps.MapControl.WPF.dll
I don't really know how to solve this. Could someone lead me to the right direction?
Upvotes: 0
Views: 469
Reputation: 17954
Take a look at using vertex reduction based on zoom level. I wrote a blog post ages ago on doing this with the Bing Maps Silverlight control: https://rbrundritt.wordpress.com/2011/12/03/vertex-reductionone-of-my-secret-weapons/ It should be fairly easy to use with the WPF control. Add a view change end event to the map and check to see if the zoom level has chanced. If it has, then update the locations of you polygons.
Alternatively, if you want to be able to render a lot more data, take a look at using the Bing Maps V8 web control in your app via a web browser control. This control has a ton of optimizations in it which allows it to render tens of thousands of polygons.
Upvotes: 1