How to use
Data has been provided for your use with this sample. It can be found at
<Your ArcGIS Developer Kit Install directory>/Samples/data/SanFranciscoNetwork.
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.
Publish a network analysis service
- Start ArcCatalog and browse to <ArcGIS Developer Kit install location>\Samples\data\SanFrancisco.
- Right-click SanFrancisco.mxd and click Publish to ArcGIS Server.
- Type SanFrancisco as the service name and click Next.
- Confirm that Network Analysis is selected and click Next.
- Click Finish.
Publish a geocoding service
- Right-click SanFranciscoLocator and click Publish to ArcGIS Server.
- Type SanFranciscoLocator as the service name and click Next.
- Click Finish and exit ArcCatalog.
Install the routing sample code
- Verify that the Web Application Developer Framework (ADF) for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
- In Windows Explorer, navigate to <ArcGIS Developer Kit install location>\Samples\ServerNET. This folder contains ArcGIS_Routing CSharp and VBNet folders.
- Open the folder of the language you are going to use (that is, CSharp or VBNet) and copy the ArcGIS_Routing_<language> folder to c:\inetpub\wwwroot. The <language> variable can be CSharp or VBNet.
- Open the IIS Manager from Control Panel, Administrative Tools, Internet Information Services (IIS) Manager, or Internet Information Services.
- In the console tree view on the left, navigate to Local Computer, Web Sites, Default Web Site. Expand Default Web Site, right-click the ArcGIS_Routing_<language> folder, and click Properties. The Properties dialog box appears.
- Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
- Start Visual Studio 2010 and open the ArcGIS_Routing_CSharp solution located in the c:\inetpub\wwwroot\ArcGIS_Routing_CSharp folder.
- In the Solution Explorer, right-click Default.aspx and select Set As Start Page.
- Change the identity specified in web.config manually or by right-clicking the project and clicking Add ArcGIS Identity. The user account specified must have access to the geographic information system (GIS) server resources referenced in the Map control.
- Build the project.
- Save the project.
Execute the routing sample
- Run the Web application.
- On the default page, add the starting and ending addresses to use for generating a route and driving directions.
- Click the Get Directions button.
- On the Directions page, use the ZoomIn, ZoomOut, Pan, and Show Entire Route tools to interact with the map. Clicking an individual link in the directions list zooms the map to that step of the route. Clicking the Reverse Directions link inverts the list of driving directions.
- Click the Printable Version link to open a window containing the current map display and a formatted list of the driving directions.
Additional information
Using the sample with your data
- This sample uses the SanFranciscoNetwork data that is installed with the software development kit (SDK). To use your data with this sample, read the data requirements and refer to the documentation on designing and building a network dataset in the ArcGIS for Desktop Help system, Contents tab, Extensions, Network Analyst.
- The network dataset must be built to include driving directions and a cost attribute, usually based on distance or time. Having a cost attribute based on time allows the sample to return driving directions with time information. If a time attribute is not included, the time values displayed in the sample will be blank.
- The map document must contain the network dataset and a route analysis layer.
- The geocoding locator must use data with the same coordinate system as the network dataset.
ArcGIS_Routing_CSharp\App_Code\AssemblyInfo.cs | Describes the assembly and specific versioning information. |
ArcGIS_Routing_CSharp\App_Code\CustomTools.cs | Code to handle when the user clicks the toolbar buttons. |
ArcGIS_Routing_CSharp\Default.aspx | User interface (UI) for adding the addresses between which the route and driving directions are based. |
ArcGIS_Routing_CSharp\Default.aspx.cs | Code behind Default.aspx. |
ArcGIS_Routing_CSharp\Directions.aspx | UI for interacting with a map of the route and the driving directions. |
ArcGIS_Routing_CSharp\Directions.aspx.cs | Code behind Directions.aspx. |
ArcGIS_Routing_CSharp\ErrorPage.aspx | UI for presenting application errors. |
ArcGIS_Routing_CSharp\ErrorPage.aspx.cs | Code behind ErrorPage.aspx. |
ArcGIS_Routing_CSharp\GenerateImage.aspx | Displays the map image for PrintPage. |
ArcGIS_Routing_CSharp\GenerateImage.aspx.cs | Code behind GenerateImage.aspx. |
ArcGIS_Routing_CSharp\Global.asax | Code for responding to application-level events raised by ASP.NET or HttpModules. |
ArcGIS_Routing_CSharp\App_Code\Global.asax.cs | Code behind Global.asax. |
ArcGIS_Routing_CSharp\App_Code\IBaseRouteFinderPage.cs | Base interface for the Route Finder Web page. |
ArcGIS_Routing_CSharp\App_Code\NetworkAnalystRouteResult.cs | Result from a Network Analyst Solve operation on route layers. |
ArcGIS_Routing_CSharp\App_Code\NetworkAnalystUtility.cs | Utility class for working with Network Analyst. |
ArcGIS_Routing_CSharp\App_Code\CustomMapHandler.cs | A custom MapHandler, enabled via entries in web.config. Where required, calls methods in ServerObjectStateModifier.cs. |
ArcGIS_Routing_CSharp\App_Code\ServerObjectStateModifier.cs | Manages stateful changes to a stateless server object. Called from Directions.aspx.cs and CustomMapHandler.cs. |
ArcGIS_Routing_CSharp\PrintPage.aspx | UI that presents a map and formatted driving directions for printing. |
ArcGIS_Routing_CSharp\PrintPage.aspx.cs | Code behind PrintPage.aspx. |
ArcGIS_Routing_CSharp\StyleSheet.css | Cascading Style Sheet (CSS) file. |
ArcGIS_Routing_CSharp\Web.config | Application configuration files containing settings specific to this sample. |
ArcGIS_Routing_VBNet\App_Code\AssemblyInfo.vb | Describes the assembly and specific versioning information. |
ArcGIS_Routing_VBNet\App_Code\CustomTools.vb | Code to handle when the user clicks the toolbar buttons. |
ArcGIS_Routing_VBNet\Default.aspx | User interface (UI) for adding the addresses between which the route and driving directions are based. |
ArcGIS_Routing_VBNet\Default.aspx.vb | Code behind Default.aspx. |
ArcGIS_Routing_VBNet\Directions.aspx | UI for interacting with a map of the route and the driving directions. |
ArcGIS_Routing_VBNet\Directions.aspx.vb | Code behind Directions.aspx. |
ArcGIS_Routing_VBNet\ErrorPage.aspx | UI for presenting application errors. |
ArcGIS_Routing_VBNet\ErrorPage.aspx.vb | Code behind ErrorPage.aspx. |
ArcGIS_Routing_VBNet\GenerateImage.aspx | Displays the map image for PrintPage. |
ArcGIS_Routing_VBNet\GenerateImage.aspx.vb | Code behind GenerateImage.aspx. |
ArcGIS_Routing_VBNet\Global.asax | Code for responding to application-level events raised by ASP.NET or HttpModules. |
ArcGIS_Routing_VBNet\App_Code\Global.asax.vb | Code behind Global.asax. |
ArcGIS_Routing_VBNet\App_Code\IBaseRouteFinderPage.vb | Base interface for the Route Finder Web page. |
ArcGIS_Routing_VBNet\App_Code\NetworkAnalystRouteResult.vb | Result from a Network Analyst Solve operation on route layers. |
ArcGIS_Routing_VBNet\App_Code\NetworkAnalystUtility.vb | Utility class for working with Network Analyst. |
ArcGIS_Routing_VBNet\App_Code\CustomMapHandler.vb | A custom MapHandler, enabled via entries in web.config. Where required, calls methods in ServerObjectStateModifier.vb. |
ArcGIS_Routing_VBNet\App_Code\ServerObjectStateModifier.vb | Manages stateful changes to a stateless server object. Called from Directions.aspx.vb and CustomMapHandler.vb. |
ArcGIS_Routing_VBNet\PrintPage.aspx | UI that presents a map and formatted driving directions for printing. |
ArcGIS_Routing_VBNet\PrintPage.aspx.vb | Code behind PrintPage.aspx. |
ArcGIS_Routing_VBNet\StyleSheet.css | Cascading Style Sheet (CSS) file. |
ArcGIS_Routing_VBNet\Web.config | Application configuration files containing settings specific to this sample. |
Download the files for all languages