More than 20 (25) waypoints.

2 posts, 0 answers
  1. Victor
    Victor avatar
    23 posts
    Member since:
    Aug 2016

    Posted 06 Jun Link to this post

    Hi there,

     

    I have read that it should be possible to add 'Viawaypoints' in combination in normal 'Waypoints'.

    I however cannot find a c# method other than  'reqRoute.Waypoints.Add(l_sWaypoint);'

    What is the right manner to have more than 25 waypoints in my route?

     

    Kind regards,

    Victor

  2. Dess
    Admin
    Dess avatar
    2107 posts

    Posted 08 Jun Link to this post

    Hello Victor, 

    Thank you for writing.  

    Currently, RadMap doesn't support ViaWaypoints. However, it is a reasonable request. I have logged it in our feedback portal and I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

    I have also updated your Telerik points.

    Currently, the possible solution that I can suggest is to create a custom BingRestMapProvider and override its BuildRoutingRequestUri method where you can add the ViaWaypoints. Here is demonstrated a sample approach:

    public class CustomBingRestMapProvider : BingRestMapProvider
    {
        protected override Uri BuildRoutingRequestUri(RouteRequest request)
        {
            List<string> waypoints = new List<string>();
     
            foreach (string str in request.Waypoints)
            {
                waypoints.Add(str.ToString());
            }
     
            request.Waypoints.Clear();
     
            Uri result = base.BuildRoutingRequestUri(request);
     
            StringBuilder path = new StringBuilder();
     
            for (int i = 0; i < waypoints.Count; i++)
            {
                if (waypoints[i].StartsWith("#VIA#"))
                {
                    path.Append("&vwp." + i + "=" + Uri.EscapeDataString(waypoints[i].Substring(5)));
                }
                else
                {
                    path.Append("&wp." + i + "=" + Uri.EscapeDataString(waypoints[i]));
                }
            }
     
            string uri = result.AbsoluteUri;
            uri = uri.Insert(uri.IndexOf('?') + 1, path.ToString() + "&");
     
            return new Uri(uri);
        }
    }
     
    public void RunRouteRequest()
    {
        //add a layer to display the route
        this.radMap1.MapElement.Layers.Add(new MapLayer());
        RouteRequest request = new RouteRequest();
        request.DistanceUnit = DistanceUnit.Kilometer;
        request.Options.Mode = TravelMode.Driving;
        request.Options.Optimization = RouteOptimization.Time;
        request.Options.RouteAttributes = RouteAttributes.RoutePath;
        request.Options.RouteAvoidance = RouteAvoidance.None;
        
        request.Waypoints.Add("Paris, France");
        request.Waypoints.Add("#VIA#Madrid, Spain");
        request.Waypoints.Add("Vienne, Austria");
        BingRestMapProvider bingProvider = this.radMap1.Providers[0] as BingRestMapProvider;
        bingProvider.CalculateRouteCompleted += BingProvider_RoutingCompleted;
        bingProvider.CalculateRouteAsync(request);
    }

    I hope this information helps. Should you have further questions I would be glad to help.

     Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top