StreetMap routing


Purpose
This sample shows how to utilize the StreetMap routing application programming interface (API). It is an implementation of a simple dialog box allowing you to set from and to stop addresses along with other routing settings, such as calculate a route, display route geometry on the map, and display driving directions text.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Open the solution file in Visual Studio and build the project.
  2. Start ArcMap.
  3. Click the Customize menu, click Toolbars, and click Routing Sample to enable the Routing Sample toolbar.
  4. Click the button on the Routing Sample toolbar to open the Routing Sample dialog box.
  5. Browse to the location of a routing service file (.rs extension) and select it in the Routing Service field.
  6. Browse to the location of an address locator file and select it in the Address Locator field.
  7. Enter the address of the starting location for driving directions in the Start section and the address of the ending location in the Finish section.
  8. In the Options section, specify the type of route, quickest or shortest, to be calculated. Specify the distance units and select the street type preference for routing using the slider bar; for example, moving the slider towards Use Local Roads causes the router to utilize non-highway roads as much as possible in the output driving directions.
  9. Optional. Click the Restrictions button to open the Restrictions dialog box. If the data referenced by the routing service file specified in step 5 contains restriction attributes, this dialog box will be populated with the available restriction parameters. Set the restrictions in this dialog box as desired.
  10. Optional. If a point feature class containing barrier features is available, browse to it in the Barriers Table field.
  11. Click the Find Route button to generate a list of driving directions and display a route graphic in ArcMap.
  12. Click the Show Directions button to open the Driving Directions dialog box, which contains the list of driving directions.

RoutingSample\RoutingForm.cs Main form and code file for the Routing Sample dialog box.
RoutingSample\DirectionsForm.cs Form and code file for the Driving Directions dialog box.
RoutingSample\RestrictionsForm.cs Form and code file for the Restrictions dialog box.
RoutingSample\RestrictControl.cs Code file for the list of restriction items in the Restrictions dialog box.
RoutingSample\RoutingCommand.cs Code file for the Routing Sample button on the Routing Sample toolbar.
RoutingSample\RoutingToolbar.cs Code file for the Routing Sample toolbar.
Download the C# files
RoutingSample\RoutingForm.vb Main form and code file for the Routing Sample dialog box.
RoutingSample\DirectionsForm.vb Form and code file for the Driving Directions dialog box.
RoutingSample\RestrictionsForm.vb Form and code file for the Restrictions dialog box.
RoutingSample\RestrictControl.vb Code file for the list of restriction items in the Restrictions dialog box.
RoutingSample\RoutingCommand.vb Code file for the Routing Sample button on the Routing Sample toolbar.
RoutingSample\RoutingToolbar.vb Code file for the Routing Sample toolbar.
Download the VB.NET files

Download the files for all languages




Additional Requirements
  • The StreetMap routing API only functions with Smart Data Compression (SDC) data and the accompanying routing service (.rs) and address locator files that are created with the DDK-Pro application. The Data & Maps data package that is shipped with ArcGIS Engine and ArcGIS Desktop contains a complete set of SDC data with routing and address files (this data can be used with the sample). On the Data & Maps and StreetMap North America DVD, navigate to the streetmap_na\data folder to access the routing service and address locator files.

Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo