i'm using Gmap.NET with C# WPF, and i'd like to add a large amount of markers (~6k) on the map. But i still can't make add them asynchronously, Map is always freezing and not responding at all, until all markers will not be added... Here is my code sample:
private void MainMap_Loaded(object sender, RoutedEventArgs e)
{
MainMap.Zoom = 12;
LoadMarkers();
}
private async void LoadMarkers()
{
await Task.Run(new Action(() =>
{
for (int i = 0; i <= 6000; i++)
{
Dispatcher.InvokeAsync(
new Action(
delegate()
{
PointLatLng point = new PointLatLng(GetRandomNumber(55.0000, 55.7510),
GetRandomNumber(36.0000, 38.9999));
var currentMarker = new GMap.NET.WindowsPresentation.GMapMarker(point);
{
currentMarker.Shape = new MarkerTemplate(this, currentMarker,
string.Empty);
currentMarker.Offset = new Point(-16, -32);
currentMarker.ZIndex = int.MaxValue;
MainMap.Markers.Add(currentMarker);
}
}
));
}
}));
}