Find a route

Show a route between two points on a map using Esri's routing service REST API.

Routing

How to use the sample

This sample uses Esri's routing service's REST API to query the closest route along the road network between two points. This service uses routing operations associated with your API Key. You can learn more about API keys and Accounts in the Mapping APIs and location services guide.

  1. Open the Routing level
  2. Click on the ArcGISMapActor in the Outliner panel.
  3. Set your API key under Authentication section in the Details panel.
  4. Click play and left-click on two locations on the map while holding shift. The route between the two points will be shown.

Note: This sample is only set up to work with mouse and keyboard.

How it works

  1. The HTTPClient is used to query the routing service's REST API.
  2. The sample makes a direct request to obtain the routing result.
  3. The Raycast API is used to determine the elevation at each breadcrumb's position to account for elevation. (Mesh colliders need to be enabled in the ArcGIS Map Component to use the Raycast API)
  4. Spline meshes are used to visualize the route segments between pairs of breadcrumbs.

Tags

routing, raycast, REST API

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.