This project has moved. For the latest updates, please go here.

Experience with many items on the map

Dec 8, 2013 at 7:01 PM
Does anyone have experience how many items you could add to the map.
I added around 1000 polylines (buildings) via Databinding.

<m:Map x:Name="MainMap" DataContext="{Binding Map, Source={StaticResource Locator}}"
Center="{Binding MapCenter, Mode=TwoWay}" TileLayer="{Binding BGtile}" ZoomLevel="{Binding Zoom, Mode=TwoWay}" >

<m:MapItemsControl ItemsSource="{Binding Areas, Mode= OneWay}" SelectedItem="{Binding SelectedArea, Mode=TwoWay}" />
….

Everything gets rendered but the responsiveness of the map gets very bad.
Is there a limit how many items you should add or any hints for performance improvement?

Regards,

Marco
Coordinator
Dec 9, 2013 at 8:25 AM
Edited Dec 9, 2013 at 8:25 AM
This is hard to tell. The total number of polylines that can be drawn smoothly certainly depends on the complexity of each one. I can easily draw 1000 polylines that contain only a few points each, but of course not if each of them is made up of 10000 points. But to answer you question, there is no general limit. It entirely depends on the complexity of your data and the performance of your machine.

Moreover it is also hard to tell if any performance improvements could be made, because you haven't shown much of your code. Are you asking for WPF, Silverlight or WinRT?
Dec 9, 2013 at 5:20 PM
Hi Clemens,

Thanks for you quick Response.
The Polylines are not complex - they are representing buildings. So most have between 4 and 20 Points.

It is WPF application. The ItemsSources is bound to an ObservableCollection of type AreaMapFeature with just have a single Attribute and inherits from MapPolyline.
The creation of the Collection is very fast and does not get changed. When the collection is created it takes maybe a second until everything is rendered (which is good enough). The problem is that panning and zooming gets very slow.


public class AreaMapFeature : MapPolyline
{
    public Int32 WayID;
}
...
public ObservableCollection<AreaMapFeature> Areas
    {
        get
        {
            return _Areas;
        }
        set
        {
            _Areas = value;
            RaisePropertyChanged("Areas");
        }
    }
Regards,

Marco
Dec 9, 2013 at 5:39 PM
an Addition:

I tested it with a very simple style.
Areas only have a stroke, no filling:

...
var ABrush = new SolidColorBrush();
            ABrush.Color = Colors.Green;
            aFeature.Stroke = ABrush;
...

still the same performance
Coordinator
Dec 10, 2013 at 10:22 AM
In order to test this I added the following code at line 170 in ViewCodel.cs:
for (double lat = 53; lat < 54; lat += 0.05)
{
    for (double lon = 8; lon < 11; lon += 0.05)
    {
        Polylines.Add(
            new VmPolyline
            {
                Locations = new LocationCollection(new Location[]
                {
                    new Location(lat, lon),
                    new Location(lat + 0.02, lon),
                    new Location(lat + 0.02, lon + 0.005),
                    new Location(lat + 0.015, lon + 0.005),
                    new Location(lat + 0.015, lon + 0.015),
                    new Location(lat + 0.02, lon + 0.015),
                    new Location(lat + 0.02, lon + 0.02),
                    new Location(lat, lon + 0.02),
                    new Location(lat, lon + 0.015),
                    new Location(lat + 0.005, lon + 0.015),
                    new Location(lat + 0.005, lon + 0.005),
                    new Location(lat, lon + 0.005),
                    new Location(lat, lon),
                })
            });
    }
}
It creates 1200 additional polylines with 12 points each to one of the MapItemsControls in the sample application. Of course the map can't be panned and zoomed as fluidly as without these additional objects, but it still feels ok to me. How does it behave on your machine?
Dec 13, 2013 at 4:44 PM
Hi Clemens,

with the demo application and the code above, I get the same behavior.
Everything is rendered fast, but zooming and panning isn’t fun.
I must say, that I don’t use it on a high end Machine (it is a core i5, with 2cores with 1.8 Ghz, onboard graphics).

Marco
Coordinator
Dec 13, 2013 at 6:40 PM
Edited Dec 13, 2013 at 6:41 PM
What can I say? I'm running this on a 5 years old Lenovo T400 with a Core 2 Duo and it still feels quite ok.

If it is no fun for you, reduce the number of items, or find a way to improve performance. This is open source.
Dec 16, 2013 at 5:47 PM
Might I suggest that it would be best to profile your app to find the bottlenecks. This might get more useful information about what needs to be optimized.