This is a migrated thread and some comments may be shown as answers.

Routing with big routes

1 Answer 122 Views
Map
This is a migrated thread and some comments may be shown as answers.
Javor
Top achievements
Rank 1
Javor asked on 13 Jul 2016, 06:54 AM
I have problem when make big route for example from Sofia, Bulgaria to Vladivostok, Russia. My code is like your example in 'Demos - Telerik UI for WPF'.
In your example and my program when I add Polyline data in my Visualization Layer
and start move on map or zoom in or zoom out map stopped for few seconds 10 or more the same is in your example. 
 

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 15 Jul 2016, 10:47 AM
Hi Javor,

The given route returned by the BingRouteProvider contains about 24000 points. All of them are set as points in the single Polyline object displayed in the RadMap. As a whole WPF engine is very sensitive when it renders big number of points (in terms of thousands). Also when you zoom / pan the radmap , the geometry of the polyline is changed / transformed and this additionally slows down the rendering.

Generally, we would suggest two approaches you can try:

1) Simplify the points displayed on the map. For example display only one from a hundred points. All route points (if your application needs them ) can be stored in a database / file / dictionary. But display only small subset of points on the map:
PolylineData routeLine = new PolylineData()
                   {
                       //Points = routeResponse.Result.RoutePath.Points,
                       ShapeFill = new MapShapeFill()
                       {
                           Stroke = new SolidColorBrush(Colors.Red),
                           StrokeThickness = 2
                       }
                   };
                   routeLine.Points = new LocationCollection();
 
                   for (int i = 0; i < routeResponse.Result.RoutePath.Points.Count; i++)
                   {
                       if (i % 100 == 0)
                       {
                           routeLine.Points.Add(routeResponse.Result.RoutePath.Points[i]);
                       }
                   }
 
                   this.routeLayer.Items.Add(routeLine);
This way you will see polyline consisting of 240 points instead of 24000. It will be fast to process by the RadMap. However, when you zoom in the details /quality will be lower.

2) Instead of single polyline, add hundreds / thousands of polylines with small number of points each.
This way you can benefit from Virtualization feature in VisualizationLayer - its a concept to request the object on demand - only the ones you need in the current viewport (defined by the center of the map and the zoom level). This approach would require storing the different polylines somehow (for example dictionary) that will be easily accessed when you need them (for certain viewport).

Regards,
Petar Mladenov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Map
Asked by
Javor
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or