C# Bing Maps SDK is painfully slow

232 views Asked by At

I'm using the latest Bing Maps SDK in a .NET Core 3.1 WPF application. Whenever I draw a large amount of lines (few thousand), it becomes painfully slow and not even worth using. I have to wait about 10 seconds before the zoom/pan updates the UI.

Am I missing something obvious? For example in leaflet, you can set the preferred mode as canvas and it speeds up drastically. I'm hoping there's something similar for the Bing Maps SDK. I'll happily accept a free alternative to the Bing Maps SDK if available.

<m:Map x:Name="mMap" CredentialsProvider="[Removed]"  Center="54.059388,-1.742378" ZoomLevel="6" />

foreach (var loc in locations)
{

    MapPolyline pl = new MapPolyline();
    pl.Locations = new LocationCollection();
    pl.Stroke = Brushes.Green;

    pl.Locations.Add(new Location(loc.Origin.Lat, loc.Origin.Lon));
    pl.Locations.Add(new Location(loc.Destination.Lat, loc.Destination.Lon));
    mMap.Children.Add(pl);
}
1

There are 1 answers

1
Duncan Lawler On BEST ANSWER

It looks like you're using the older WPF map control. That control used XAML UI elements to draw map canvas items like polylines. XAML UI elements will not perform well for large numbers of objects. You should see if the UWP map control will work for you.

Maps and location overview

This is the latest map control which is designed for UWP applications, but it can be hosted in WPF applications through XAML islands if you need it. It should perform much better for large numbers of map annotations as it doesn't use XAML UI elements.