How to add the large number of icons in map at once?

Within this forum we want to offer discussions all around our .NET based Map control including all .Net-language specific questions concerning calls of the xServer-API. Attention: xServer-relevant concepts can be found in further forums such as xRoute or xTour.

How to add the large number of icons in map at once?

Postby webdirekt » Tue Aug 22, 2017 8:57 am

Code snippet :
---------------------------------------------------
// We are having shape layer in which we are going to add map icons
ShapeLayer _globalMapIconLayer = new ShapeLayer("IconLayer") { Caption = "IconLayer" };

// adding layer in map
wpfMapControl.Layers.Add(_globalMapIconLayer);

// We are adding map icon one by one using list i.e mapIconList
// each item in list contains geo-coordinates i.e X-coordinate and Y-coordinate
for(mapIconListIndex = 0 ; mapIconListIndex < mapIconList.Count ; mapIconListIndex ++)
{
// We are calling separate method to add each map icon in shape layer one by one
AddIcon(new Point(mapIconList[(mapIconListIndex].X, mapIconList[(mapIconListIndex].Y)
}

// method used to add map icon
public void AddIcon(Point point)
{
// We are creating map icons using the user control
// Icon is user control name
// 52 is width and 44 is height of icon
Icon icon = new Icon(52, 44);

// We are creating the map icon using the image of user control Icon
MapIcon mapIcon = new MapIcon(icon.GetImage())
{
ToolTip = new ToolTip()
{
Content = "Icon ToolTip",
Foreground = new SolidColorBrush(Colors.LightGray),
Background = new SolidColorBrush(Colors.Black),
}
};

// We are adding right click event handler to each map icon
mapIcon.MouseRightButtonDown += pin_MouseRightButtonDown;

// Add the shape to our shape layer
_globalMapIconLayer.Shapes.Add(mapIcon);

// We are setting location of map icon on shape canvas
ShapeCanvas.SetLocation(mapIcon, point);
ShapeCanvas.SetAnchor(mapIcon, LocationAnchor.Center);
}


In our application issue is that suppose we are having 20000 map icons in the list, it is very slow to add those number of icons one by one.

Is there any optimized way to add large number of icons in the map ?
User avatar
webdirekt
 
Posts: 28
Joined: Wed Jul 15, 2015 10:18 am

Re: How to add the large number of icons in map at once?

Postby Bernd Welter » Tue Aug 22, 2017 9:10 am

Hello Chris, Paul,

how about this example from the Demo center? Usually an aggregation of 20.000 objects into various grouped icons is a valid approach.

Demo Center.map clustering.png
XServer.NET Demo Center
Usecase Clustering (maps)

Or would you really like to see 20.000 different objects on the same map?

Best regards,
Bernd
Bernd Welter
Senior Technical Consultant Developer Components
PTV GROUP - Germany

Bernd at Youtube
User avatar
Bernd Welter
Site Admin
 
Posts: 1336
Joined: Mon Apr 14, 2014 10:28 am

Re: How to add the large number of icons in map at once?

Postby webdirekt » Tue Aug 22, 2017 9:50 am

Hi Bernd, we can not use clustering in our scenario, is there any alternate solution ?
User avatar
webdirekt
 
Posts: 28
Joined: Wed Jul 15, 2015 10:18 am

Re: How to add the large number of icons in map at once?

Postby Bernd Welter » Tue Aug 22, 2017 10:05 am

Then we need the WIZZARD OF GUI!
I'll ask Oli for it ;-)
Bernd Welter
Senior Technical Consultant Developer Components
PTV GROUP - Germany

Bernd at Youtube
User avatar
Bernd Welter
Site Admin
 
Posts: 1336
Joined: Mon Apr 14, 2014 10:28 am

Re: How to add the large number of icons in map at once?

Postby Oliver Heilig » Tue Aug 22, 2017 10:53 am

Generally that's a tough problem, and there's no simple answer for it. But you can classify the solutions bythese three categories:

  • Use POI-Clustering
    This handles the problem by reducing the total count of elements which have to be created. But this may be not appropriate for every use case.
  • Optimize the Shape-Layer Rendering
    See https://github.com/ptv-logistics/xserve ... erformance for examples how this affects the performance, especially for VDI (= virtual desktop infrastructure) environments.
  • Use a custom GDI Renderer
    This doesn't create individual wpf elements for every icon, but renders a single image for all icons, and overlays that on the map. We have a sample that uses SharpMap (https://sharpmap.codeplex.com/) for rendering the objects, see https://github.com/ptv-logistics/SharpMap.Widgets. A caveat is that you have to implement the hit-testing (e.g. for clicking) by yourself. A nice benefit is that this code can also be reused for web applications.

Oli
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany

https://github.com/oliverheilig/
User avatar
Oliver Heilig
 
Posts: 122
Joined: Tue May 13, 2014 12:10 pm
Location: Karlsruhe, Germany


Return to PTV xServer.NET (Admin=OH)

cron