c# - Bing RouteOptimization doesnt have any effect on routeService.CalculateRoute -


it seems routeservice.calculateroute(routerequest) not take effect routerequest.options. have tried setting routeoptimization.minimizedistance , routeoptimization.minimizetime; , neither seem adjust best route. seems calculateroute calculates waypoints depending on order in array of waypoints. know doing wrong?

            waypoint[] waypoints = new waypoint[waypointinfo.count + 1]; // +1 store              waypoints[0] = new waypoint();             waypoints[0].description = "store";             waypoints[0].location = new routeservice.location();             waypoints[0].location.latitude = store.latitude;             waypoints[0].location.longitude = store.longitude;              (int = 0; < waypointinfo.count; i++)             {                 waypoints[i+1] = new waypoint();                 waypoints[i + 1].description = waypointinfo[i].address+ " - " +waypointinfo[i].name;                 waypoints[i+1].location = new routeservice.location();                 waypoints[i + 1].location.latitude = waypointinfo[i].locations.latitude;                 waypoints[i + 1].location.longitude = waypointinfo[i].locations.longitude;              }                routerequest routerequest = new routerequest();             routerequest.credentials = new microsoft.maps.mapcontrol.wpf.credentials();             routerequest.credentials.applicationid = "bing api key";              // want minimum distance or minimum time?             routeoptions myrouteoptions = new routeoptions();             myrouteoptions.mode = travelmode.driving;             myrouteoptions.optimization = routeoptimization.minimizedistance;             myrouteoptions.trafficusage = trafficusage.trafficbasedtime;             routerequest.options = myrouteoptions;              //routerequest.userprofile = new userprofile { distanceunit = routeservice.distanceunit.kilometer };              routerequest.waypoints = waypoints;              // make calculate route request             routeserviceclient routeservice = new routeserviceclient();             routeresponse routeresponse = routeservice.calculateroute(routerequest);                double daydistance = 0;                            directions.clear();              if (routeresponse.result.legs.length > 0)             {                 int instructioncount = 0;                 int legcount = 0;                  foreach (routeleg leg in routeresponse.result.legs)                 {                      legcount++;                     if (legcount > 1)                     {                         directions.append(" " + "\n");                     }                      foreach (itineraryitem item in leg.itinerary)                     {                          instructioncount++;                         directions.append(string.format("{0}. {1} {2}\n",                             instructioncount, item.summary.distance, item.text));                         daydistance += item.summary.distance;                     }                 } 

}

the waypoints used said. bing, route should in order. works , you're not doing wrong.

http://msdn.microsoft.com/en-us/library/cc966873.aspx


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -