Common Select Buffer tool


Purpose
This sample demonstrates how to use the Web Application Developer Framework (ADF) graphics resource in a map to show selected features. The Web ADF graphics resource is an in-memory, spatially enabled .NET DataSet managed in the Web-tier. Each graphics resource can contain many graphics layer types, such as ElementGraphicsLayer and FeatureGraphicsLayer. Graphics and selected features can be rendered as a temporary layer in a server-based resource, such as ArcIMS or ArcGIS for Server. However, using the Web ADF graphics layer offers the following benefits:
  • It is maintained in the Web-tier, which means it is managed in the same way as other resources in the map. For example, if you have ArcGIS for Server and ArcIMS resources in the map, the graphics layer resource can be displayed on top of both. If selected features are rendered in an ArcIMS acetate layer, they can be covered by any other resource drawn above the ArcIMS resource.
  • It enables you to use the generic interfaces of the Web ADF, known as the Common API, to render selected features without knowing the type of data source. For example, instead of using the ArcGIS Server ArcObjects application programming interface (API) to query features in a layer, use the Common API's IQueryFunctionality.Query() method, which also works with ArcIMS and other data source types.
  • It can use standard Web ADF symbolization to render the selected features consistently. This eliminates the need to define the same renderer or symbol (look and feel) for selected features in different data sources.
Buffering in the Web-tier is limited to the capabilities of the .NET Framework. In this sample, the Buffer tool uses System.Drawing.Drawing2D.GraphicsPath to generate an ellipse. The Web ADF and .NET Framework do not inherently contain a projection engine, so the coordinate system of the map supports the generation of accurate buffers (for example, at a minimum, using a projected coordinate system). The Selection and Buffer tools require that the Web ADF implementation of the data source (ArcGIS for Server, ArcIMS) support IQueryFunctionality.

How to use

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.

At 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 Developer Kit install location>\Samples\ServerNET\Common_SelectBufferTool.
  3. Open the folder of the language you are going to use (that is, CSharp or VBNet) and copy the Common_SelectBufferTool_<language> folder to c:\inetpub\wwwroot. The <language> variable can be 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. Expand Default Web Site, right-click the Common_SelectBufferTool_<language> folder, and click Properties. The Properties dialog box appears.
  6. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  7. Start Microsoft Visual Studio 2010 and open the Common_SelectBufferTool_<language><vs_version> solution (for example, Common_SelectBufferTool_CSharp2010.sln) located in c:\inetpub\wwwroot\Common_SelectBufferTool_<language>.
  8. In the Solution Explorer, right-click Default.aspx, and select Set As Start Page.
  9. Open the Default.aspx page in design view, open the properties window for the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box appears.
  10. Add or change the MapResourceItem associated with a map service (for example, ArcGIS for Server, ArcIMS, and so on).
  11. If necessary, set the run time identity of the Web application by following one of the next two steps. If not necessary, proceed to Step 14.
  12. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At run time, that identity is established by the Web application. Only one identity can be used to define access to the ArcGIS for 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 the Solution Explorer and selecting the Add ArcGIS Identity option. Add the identity credentials that will be used to access ArcGIS for Server local resources at run time. This information is added to the web.config file in a standard ASP.NET identity tag. If the Encrypt identity in web.config check box is selected, the identity tag is encrypted; otherwise, the username and password are stored as clear text.
  13. Open the web.config file, add an <identity> element in <system.web>, set the impersonate attribute to true, add a username and password attribute, and set them to a valid user account. If you are working with ArcGIS for Server local data sources, ensure the account has access to the geographic information system (GIS) server resources referenced in the Map control.
  14. Save the project.
  15. Click the Debug drop-down menu and click Start Debugging.

At run time
  1. Browse to the viewer uniform resource locator (URL), for example, http://localhost/Common_SelectBufferTool_CSharp.
  2. Click a layer in the Toc or use the Select Features In drop-down box to activate a layer from which to select features.
  3. In the toolbar above the map, click Select Features.
  4. Click and drag a rectangle on the map that intersects features in the active layer. Features that intersect the rectangle are added to the ElementGraphicsLayer in the Selection Graphics resource and displayed above other resources in the map. A GraphicElement is created for each feature before being added to the ElementGraphicsLayer.
  5. Select the Display Selection in Table check box, and use the Select Features tool to make another selection on the map. The attributes of the selected features are rendered at the bottom of the page in a GridView.
  6. In the toolbar above the map, click Buffer Point - Select Features. The Buffer Distance text box appears.
  7. Add a distance in map units, click the map to generate a buffer, and select features. The buffer polygon is rendered in semi-transparent yellow and the selected features are rendered in semi-transparent green.
  8. Depending on the map units, you might need to set the value of the flattening variable in the buffer tool code. A value for decimal degrees, and meters or feet is provided. The flattening value is used to determine the distance between vertices in the buffer polygon.

Common_SelectBufferTool_CSharp\Default.aspx User interface (UI) for the Web application.
Common_SelectBufferTool_CSharp\Default.aspx.cs Code behind the UI.
Common_SelectBufferTool_CSharp\App_Code\CustomControls.cs Code file that extends the Toc control to enable more interactivity (for example, define an active layer).
Common_SelectBufferTool_CSharp\App_Code\CustomTools.cs Code file containing implementation of select and buffer-select tools.
Common_SelectBufferTool_CSharp\App_Code\Utility.cs Code file containing shared utility methods.
Download the C# files
Common_SelectBufferTool_VBNet\Default.aspx User interface (UI) for the Web application.
Common_SelectBufferTool_VBNet\Default.aspx.vb Code behind the UI.
Common_SelectBufferTool_VBNet\App_Code\CustomControls.vb Code file that extends the Toc control to enable more interactivity (for example, define an active layer).
Common_SelectBufferTool_VBNet\App_Code\CustomTools.vb Code file containing implementation of select and buffer-select tools.
Common_SelectBufferTool_VBNet\App_Code\Utility.vb Code file containing shared utility methods.
Download the VB.NET files

Download the files for all languages