MapPolyline isssues

2 posts, 0 answers
  1. figueiredorj
    figueiredorj avatar
    68 posts
    Member since:
    Mar 2011

    Posted 04 Aug 2011 Link to this post

    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);

  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 09 Aug 2011 Link to this post

    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 >>

  3. DevCraft banner
Back to Top