Description:
This sample demostrates how to utilize Web ADF graphic resources 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 within a server-based resource, such as ArcIMS or ArcGIS Server (see the respective ArcGIS Server and ArcIMS samples). However, using the Web ADF graphics layer instead offers a number of benefits:
1) It's maintained in the Web-tier, which means it’s managed like any other resource in the map. For example, if you have an ArcGIS Server and ArcIMS resource in the map, the graphics layer resource can be displayed on top of both. If selected features were rendered in an ArcIMS acetate layer, they may be covered by any other resource drawn above the ArcIMS resource.
2) 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 API to query features within a layer, merely use the Common API's IQueryFunctionality.Query() method, which also works for ArcIMS and other data source types.
3) 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 a 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 should support the ability to generate accurate buffers (e.g. at a minimum, use a projected coordinate system).
The selection and buffer tools require that the Web ADF implemenation of the data source support IQueryFunctionality (e.g. ArcGIS Server, ArcIMS, ArcWeb).
Products: Server: C#, VB.NET
Platforms: WindowsMinimum ArcGIS Release: 9.2 |
How to use:
- Design Time:
- 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.
- In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip Common_SelectBufferToolCSharp.zip or Common_SelectBufferToolVBNet.zip to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
- In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Copy the folder, Common_SelectBufferTool_<language>, to c:\inetpub\wwwroot. The <language> variable may be either 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 then right-click the Common_SelectBufferTool_<language> folder and click Properties.
- On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
- Launch Microsoft Visual Studio 2005 and open the Common_SelectBufferTool_<language> solution (for example, Common_SelectBufferTool_CSharp.sln) located in c:\inetpub\wwwroot\Common_SelectBufferTool_<language>.
- In the Solution Explorer, right-click Default.aspx and select 'Set As Start Page'.
- 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.
- Add or change the MapResourceItem associated with a map service (ArcGIS Server, ArcIMS, ArcWeb, etc.).
- If necessary, set the runtime identity of the Web application:
- 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-
- 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.
- Save the project.
- Click the "Debug" drop-down menu and choose "Start".
- Run Time:
- Browse to viewer's URL (for example, http://localhost/Common_SelectBufferTool_CSharp).
- Use the "Select Features In" drop down box to activate a layer from the first resource in the map.
- In the toolbar above the map, click "Select Features".
- Click and drag a rectangle on the map that intersects features in the active layer. Features which intersect the rectangle will be added to a 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.
- Check the box "Display Selection in table". Use the Select Features tool and make another selection in the map. The attributes of the selected features should be rendered at the bottom on the page in a GridView.
- In the toolbar above the map, click "Buffer Point - Select Features".
- In the Buffer distance textbox, enter a distance in map units.
- Click on the map to generate a buffer and select features. The buffer polygon should be rendered semi-transparent yellow. The selected features should be rendered semi-transparent green.
- Depending on the units of the map, you may 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.sln |
The solution file. |
| Default.aspx |
User interface for the Web application |
| Common_SelectBufferTool_CSharp/Default.aspx.cs
|
The code behind the user interface |
| Common_SelectBufferTool_CSharp/App_Code/SelectTool.cs
|
Class library containing implementation of select tool. |
| Common_SelectBufferTool_CSharp/App_Code/BufferTool.cs
|
Class library containing implementation of buffer tool. |
Download the C# files
| Common_SelectBufferTool_VBNet.sln |
The solution file. |
| Default.aspx |
User interface for the Web application |
| Common_SelectBufferTool_VBNet/Default.aspx.vb
|
The code behind the user interface |
| Common_SelectBufferTool_VBNet/App_Code/SelectTool.vb
|
Class library containing implementation of select tool. |
| Common_SelectBufferTool_VBNet/App_Code/BufferTool.vb
|
Class library containing implementation of buffer tool. |
Download the VB.NET files
Download the files for all languages