How to draw out routes in map?

403
1
06-14-2019 09:46 AM
GerardoHernandez
New Contributor

Hello,

I have an application that generates routes and stops built in .net using the REST API and managed to generate all json, but I don't know how to draw on the map the json "out_routes" and "out_stops".

Any idea?

Thanks!

0 Kudos
1 Reply
ScottAndersonGQ
New Contributor III

I know this is late but I return the data that comes back from: SolveVehicleRoutingProblem/jobs/{{jobId}}/results/out_Routes?token=...

On the frontend I have JS that looks like:

 

//store all routes
var polyArr = [];
//make line
for (var route of routes) {
   var polyline = {
      type: "polyline",
      paths: route.geometry.paths
   };
   //make symbol
   var polylineSymbol = {
      type: "simple-line", // autocasts as SimpleLineSymbol()
      color: [50, 50, 50],
      width: 4
   };
   //Put it together in a Graphic object
   let polylineGraphic = new Graphic({
                geometry: polyline,
                symbol: polylineSymbol,
                attributes: polylineAtt,
                popupTemplate: {...}
    })
   //Add route object to route array
    polyArr.push(polylineGraphic);
}
//route layer is a graphic layer that was previously added to the map
routeLayer.addMany(polyArr);

 

Hope this helps someone. 

0 Kudos