Common Add Custom Tool



Description:

This sample demonstrates how to add a custom tool, command, and dropdown to a Web application using the Web ADF. The tool uses the Web ADF Common API to identify each layer in a map that intersects a user point and return a table of attribute values for each layer. Note that no specific data source type is required. This sample should work with all data sources that implement the Common API interface IMapFunctionality (e.g. ArcGIS Server, ArcIMS, ArcWeb, OGC\WMS). The Identify All tool will work with all data sources that implement the Common API interface IQueryFunctionality (e.g. ArcGIS Server, ArcIMS, ArcWeb).

This sample assumes a map service has been created from the USA_Data map document included with the sample data located here:

<ArcGIS install location>\DeveloperKit\SamplesNet\Server\data\USA
Products:
Server: C#, VB.NET

Platforms: Windows

Minimum ArcGIS Release: 9.2

How to use:
  1. Design Time:
    1. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
    2. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip Common_AddCustomToolCSharp.zip or Common_AddCustomToolVBNet.zip to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
    3. In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Copy the folder, Common_AddCustomTool_<language>, to c:\inetpub\wwwroot. The <language> variable may be either CSharp or VBNet.
    4. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services
    5. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site.
    6. Expand Default Web Site then right-click the Common_AddCustomTool_<language> folder and click Properties.
    7. On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
    8. Launch Microsoft Visual Studio 2005 and open the Common_AddCustomTool_<language> solution (for example, Common_AddCustomTool_CSharp.sln) located in c:\inetpub\wwwroot\Common_AddCustomTool_<language>.
    9. In the Solution Explorer, right-click Default.aspx and select 'Set As Start Page'.
    10. Open the Default.aspx page in design view. Open the properties window for the MapResourceManager control. Click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog should display.
    11. Add or change the MapResourceItem associated with a map service (ArcGIS Server, ArcIMS, ArcWeb, etc.).
    12. If necessary, set the runtime identity of the Web application:
      1. At design-time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At runtime, that identity is established by the Web application. Only one identity can be used to define access to all ArcGIS Server local data sources in a single Web application. This identity can be explicitly defined when building the Web ADF application in Visual Studio by right-clicking the Web project in Solution Explorer, and selecting the Add ArcGIS Identity option. Enter the identity credentials which will be used to access ArcGIS Server local resources at runtime. This information will be added to the web.config file within a standard ASP.NET identity tag. If the "Encrypt identity in web.config" checkbox is checked, the identity tag will be encrypted, otherwise the username and password will be stored as clear text.
        -or-
      2. Open the web.config file and add an <identity> element within <system.web>. Set the impersonate attribute to "true". Add a userName and password attribute and set them to a valid user account. If working with ArcGIS Server Local data sources, make sure the account has access to the GIS Server resources referenced in the Map control.
    13. Save the project.
    14. Click the "Debug" drop-down menu and choose "Start".
  2. Run Time:
    1. Browse to viewer's URL (for example, http://localhost/Common_AddCustomTool_CSharp).
    2. In the toolbar above the map, click "Identify All".
    3. Click on an area of the map where features in more than one layer are present.
    4. All feature attributes in each layer (note that a single MapResourceItem may contain multiple layers) that intersect the location of the click event will be returned in a GridView below the map. One GridView will be returned for each layer. The title of the table consists of the MapResourceInfo item name, the layer id, and the layer name.
    5. Click on the Zoom to Point tool and click on the map. Note that the map centers on the user click and zooms in.
    6. Click on the Extent Command button in the toolbar. As a command, the action occurs when the button is pressed. In this case, the extent of the map changes to include the southwest United States in decimal degrees. If the map is not associated with a geographic coordinate system, this command may not function as expected. To change the extent, open the CustomToolLibrary code file and modify the ExtentCommand class.
    7. Click on the drop down list to select a direction the map should pan. Four directions are provided: NorthWest, NorthEast, SouthWest, and SouthEast.
    8. Click on the PreviousExtent and NextExtent commands below the map to traverse the array of extents viewed.

Download the C# files
Default.aspx User interface for the Web application
Common_AddCustomTool_CSharp/Default.aspx.cs The code behind the user interface
Common_AddCustomTool_CSharp/App_Code/CustomToolLibrary.cs Class library containing implementation of custom tools, commands, and drop downs.
Common_AddCustomTool_CSharp/App_Code/IBaseToolbarRefresh.cs Interface implemented by the Page for custom classes to interact with custom page content. In this case, its used by custom classes in App_Code to refresh a toolbar in the page and synchronize client (browser) with Web application state.
Download the VB.NET files
Default.aspx User interface for the Web application
Common_AddCustomTool_VBNet/Default.aspx.vb The code behind the user interface
Common_AddCustomTool_VBNet/App_Code/CustomToolLibrary.vb Class library containing implementation of custom tools, commands, and drop downs.
Common_AddCustomTool_VBNet/App_Code/IBaseToolbarRefresh.vb Interface implemented by the Page for custom classes to interact with custom page content. In this case, its used by custom classes in App_Code to refresh a toolbar in the page and synchronize client (browser) with Web application state.

Download the files for all languages