Select to view content in your preferred language

Get routing direction

390
1
07-06-2022 06:29 PM
ElohoKennedy
New Contributor

How do I display routing directions on the map without clicking the mapView

 

I already have the routing coordinates in my code which are dynamic

I just want to display it on the map without clicking the map 

Tags (2)
0 Kudos
1 Reply
Noah-Sager
Esri Regular Contributor

Hi @ElohoKennedy, you have two options: RouteLayer and Directions widget, or just the RouteLayer.

You can dynamically update the Directions widget with programmatically created RouteLayers. Here's a blog and a demo covering this functionality. Routing directions are displayed inside the Directions widget:

https://www.esri.com/arcgis-blog/products/js-api-arcgis/developers/changing-directions/

https://noashx.github.io/blog/ChangingDirections.html

You could also just use the RouteLayer, and then handle the display of the directions yourself.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-RouteLayer.html

https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=layers-routelayer

To display the directions, you'll want to work with the results of RouteLayer.solve():

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-RouteLayer.html#solve

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-RouteLayer.html#RouteLayer...

https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-RouteInfo.html

Hope this helps!

0 Kudos