Add routing service to json for JS app

280
1
03-13-2024 03:38 PM
Labels (1)
forestknutsen1
MVP Regular Contributor

Hi I have been asked to add a routing service to a json config file for a third party JS app. We don't have a routing service on our AGS/Portal so I think using the one from Esri is the best path at this time.

Looks like that url should be:

https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World

I know that it is going to use AGOL credits but I am not sure how to wire it up to our organization's account.

The json sample the vendor provided is:

  

 

 

  "routing": {
    "url": "",
    "distanceFormat": "esriKilometers"
  },

 

 

Tags (1)
1 Reply
Raul_Jimenez
Esri Contributor

Hi @forestknutsen1,

Is you are going to use JavaScript you can:

  1. Use ArcGIS REST JS routing package, it is a lightweight wrapper to easily use with our APIS which works in the frontend and in the backend.
  2. But if you are familiar with the ArcGIS Maps SDK for JS, you can use the esri/rest/route module, in the client but also in NodeJS like shown in this tutorial.

The Routing chapter in the Mapping APIs and location services guide has a ton of resources to help you with that, including links to the Routing & Directions API collection in Postman.

So, you can use route.arcgis.com or route-api.arcgis.com, bot are enhanced endpoints and are functionally equivalente (more).

In terms of how to authorize, you have all options available, I would recommend API keys or app credentials, unless the end user of the app has an ArcGIS identity & the app request authentication (types of authentication comparison).

And last but not least, should you use ArcGIS Online?? Maybe, you can also use a free ArcGIS Developer account which is tight to ArcGIS Platform and includes:

  • A free tier (20,000 simple routes, 5,000 service areas, ...)
  • And I can be also used for commercial use.

More info about differences between account/product types in: Products, subscriptions, and accounts:

Screenshot 2024-03-14 at 00.01.47.png

I hope this helps.

Cheers!,
Raul

0 Kudos