ArcGIS Add Graphics



Description:

This sample demonstrates how to add custom graphics to an ArcGIS Server service and display the results in a Web ADF Map control. In a Web ADF application, graphics can be drawn in the client-tier (browser), web-tier (Web application), or the server-tier (map service). In this sample, graphics are drawn in the server-tier utilizing data source specific capabilities of an ArcGIS Server map service exposed via the ArcGIS Server SOAP API.
The sample contains a Web ADF toolbar, a few of tools, and a command. The tools illustrate how to add text and geometry (point, line, polygon) to an ArcGIS Server data source, both local and Internet. The ArcGIS Server SOAP API is utilized via a set of Value objects and a Web service (Internet data source) and DCOM proxy (Local data source) to the ArcGIS Server service. The Value objects provide a set of native .NET classes to create and define properties of graphic elements on the client. The ArcGIS Server MapFunctionality provides a MapDescription property to access the Web ADF managed MapDescription Value object. A set of graphic elements can be added the an ArcGIS Server service via MapDescription.CustomGraphics property. Modifications to the MapDescription are maintained in session state by the Web ADF. As a result, custom graphic elements added are retained across requests to the server.
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 ArcGIS_AddGraphicsCSharp.zip or ArcGIS_AddGraphicsVBNet.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, ArcGIS_AddGraphics_<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 ArcGIS_AddGraphics_<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 ArcGIS_AddGraphics_<language> solution (for example, ArcGIS_AddGraphics_CSharp.sln) located in c:\inetpub\wwwroot\ArcGIS_AddGraphics_<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 an ArcGIS Server map service.
    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/ArcGIS_AddGraphics_CSharp).
    2. In the toolbar above the map, click "Add Text Tool".
    3. Click on the map and notice that the text “TOOL” is added to the map.
    4. In the toolbar above the map, click “Add Text Command”.
    5. The text “COMMAND” should be drawn on the map image at the image pixel location 200,200 (from the upper left corner of the image).
    6. In the toolbar above the map, click "Add Point Tool".
    7. Click on the map and notice that a green diamond point graphic is added to the map.
    8. In the toolbar above the map, click "Add Polyline Tool".
    9. Click on the map and digitize a line. Double-click to finish digitizing. Notice that a green line graphic is added to the map.
    10. In the toolbar above the map, click "Add Polygon Tool".
    11. Click on the map and digitize a polygon. Double-click to finish digitizing. Notice that a solid green polygon graphic is added to the map.
    12. Click on the Clear Graphics button to clear all ArcGIS Server graphics in the map.

Download the C# files
Default.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddGraphics_CSharp/Default.aspx.cs Code behind the aspx file. References Web ADF libraries and functionality.
CustomGraphics.csproj References the class library project containing custom tools.
ArcGIS_AddGraphics_CSharp/App_Code/TextTool.cs Implementation class for custom tool to create a text graphic element.
ArcGIS_AddGraphics_CSharp/App_Code/PointTool.cs Implementation class for custom tool to create a point graphic element.
ArcGIS_AddGraphics_CSharp/App_Code/PolylineTool.cs Implementation class for custom tool to create a polyline graphic element.
ArcGIS_AddGraphics_CSharp/App_Code/PolygonTool.cs Implementation class for custom tool to create a polygon graphic element.
Download the VB.NET files
Default.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddGraphics_VBNet/Default.aspx.vb Code behind the aspx file. References Web ADF libraries and functionality.
CustomGraphics.vbproj References the class library project containing custom tools.
ArcGIS_AddGraphics_VBNet/App_Code/TextTool.vb Implementation class for custom tool to create a text graphic element.
ArcGIS_AddGraphics_VBNet/App_Code/PointTool.vb Implementation class for custom tool to create a point graphic element.
ArcGIS_AddGraphics_VBNet/App_Code/PolylineTool.vb Implementation class for custom tool to create a polyline graphic element.
ArcGIS_AddGraphics_VBNet/App_Code/PolygonTool.vb Implementation class for custom tool to create a polygon graphic element.

Download the files for all languages