This is a migrated thread and some comments may be shown as answers.
MapPolyline isssues
1 Answer 31 Views
Map
This is a migrated thread and some comments may be shown as answers.
figueiredorj
Top achievements
Rank 1
figueiredorj asked on 04 Aug 2011, 05:07 PM
Hi.

I am using  MapPolyline to draw paths on map.

Doing that I have two issues:
  • In first place I am only been capable of creating a MapPolyline adding location by location. Is a way of adding for example a List of Locations?
  • I have another issue that don't , know if is related to it or not but in part I know it does. If I add all my paths in a single polyline there isn't much lag; however If I split it by time (10:00, 11:00, 12:00,...) it takes too much time loading it in map. (I do believe that bing maps has something to do with it too, but I am unsure if I could use a more performing object or load it in a better way.)

I also set direction with arrows by 100 to 100 meters...
my code:

  var line = new MapPolyline() { Stroke = color, StrokeThickness = 2 };
    line.Points = new LocationCollection();
 
    int auxDistance = 0;
    IGeo last = null;
    foreach (var point in route)
    {
        if (auxDistance > 100)
        {
            auxDistance = 0;
            BuildArrowAtPoints(last.Location, point.Location, color);
        }
        auxDistance += point.IODistance;
        last = point;
        line.Points.Add(point.Location);
    }
    RoutesLayer.Items.Add(line);
}
SetBestView(SpeedLayer, this.Map);

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 09 Aug 2011, 03:08 PM
Hi Figueiredorj,

You can create a collection of the locations first, and then assign it to the polyline. For example:

var line = new MapPolyline() { Stroke = color, StrokeThickness = 2 };
LocationCollection points = new LocationCollection();
  
int auxDistance = 0;
IGeo last = null;
  
foreach (var point in route)
{
   if (auxDistance > 100)
   {
       auxDistance = 0;
       BuildArrowAtPoints(last.Location, point.Location, color);
   }
  
   auxDistance += point.IODistance;
   last = point;
   points.Add(point.Location);
}
 
line.Points = points;
RoutesLayer.Items.Add(line);

I hope this approach will help you resolve your second problem as well. Anyway, could you please, provide us with some more information on your polylines:

1. How many polylines you add to the information layer?
2. What is min, max and average number of points in the 1 polyline?
3. What is total number of points in all polylines?

Kind regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
Map
Asked by
figueiredorj
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or