This post was republished to Campus Support for ArcGIS, ...
at [Link] PM 4/4/2008
Select Tool Task for Web ADF
Select Tool Task
Installed on 04/04/2008 and is available in ArcGIS Manager as a Task
For version 9.2 of ArcGIS Server, ArcIMS or the Web ADF Runtime
Download from: [Link]
This sample custom task allows a Web ADF user to select features by clicking or drawing a shape on the
map. The user chooses a layer to select from, along with the type of tool, and then clicks on the map to
select. Available tools are: point, rectangle, line/polyline, polygon, and circle. Selected features are
highlighted on the map and their attributes are included in the task results.
The administrator may limit the layers available for selection. See the “Configuring the Task” section
below for this and other configurable settings.
Source code (C#) is included with the task in a zip file. Unzip to a suitable location and open the project
(.csproj file) in Visual Studio 2005 (or Visual C# Express). You can also create a test harness for the
project in Visual Studio by adding a website to the solution, and adding the task project as a reference to
the website. You can then debug the project by adding the task to a website page and running in debug
mode. Location of source is: M:\ArcGISServer\Data\CustomTasks\SelectToolTask\
Configuring Task in Visual Studio
If you add the Select Tool Task to a web page via Visual Studio, you must set the TaskResultsContainer
property in the Visual Studio dialog for the task. After dragging the task onto the web page (usually into
a TaskManager control), highlight the task. Its properties page will be available, usually on the lower
right of Visual Studio. Set these properties:
• TaskResultsContainer property –set to the TaskResultsContainer that will display the attributes
of selected features.
• Map (in SelectToolTask group) – set to the Map control on the page. The drop-down should list
available Map control(s). If no Map control is set, the first Map control found on the page will be used.
• Optionally, set other properties (all in SelectToolTask group except where noted), including:
o SelectionLayerNames: if specified, only these layers may be selected from. The layer names will
be shown in the drop-down list in the browser. If blank, all selectable vector layers may be selected
from. If only one layer is specified, the browser’s drop-down list will be read-only. To set the list, click
the ellipsis button in the SelectionLayerNames property, or use the “smart tag” that appears by clicking
the upper right of the task control in Visual Studio.
o RenderSelectedSet: if true, all selected features will immediately be highlighted on the map with
the SelectedSetColor. This highlighting may be turned on/off with the check-box for the entire selection
in the Task Results. If false, features must be highlighted individually via check-boxes for individual
features. Default is true.
o SelectedSetColor: if RenderSelectedSet is true, selected features will be highlighted with this
color. If this color is set to empty, the selected features will not be highlighted, even if
RenderSelectedSet is true.
o FeatureSelectionColor (in Task group): color to highlight features when the checkboxes next to
individual features are checked.
o HidePreviousSelection: if true, all highlights for features selected previously with the
SelectToolTask will be removed upon selecting a new set. Previously selected sets may always be
highlighted again by clicking their checkboxes. Default is true.
Using the Select Tool Task
To select features in the browser:
1. Zoom/pan the map to the location where you want to select features.
2. Display the Select Tool Task if necessary by clicking its link in the task menu.
3. In the Select Tool task’s panel, use the drop-down list to choose a layer to select from. (If the
administrator limits the selection to a single layer, the drop-down list just displays the layer name.)
4. In the task’s panel, click a tool to use. By default the available tools are: point, rectangle, line,
polygon, and circle.
5. Click on the map to select feature(s).
• Point tool: click once to select a feature.
• Rectangle tool: click and hold at one corner, drag to other corner and release.
• Line and Polygon tools: click and release at each vertex to draw a line/polygon. Double-click at
last vertex.
• Circle tool: click and release at center, move cursor to outer edge of circle, and click again.
6. Features found are listed in the Task Results panel. Expand the task results item to see attributes
of these features. Features may be highlighted immediately, or you may need to highlight them
individually by expanding the task results and clicking on individual features.
Installing the Select Tool Task Manually
These steps are only necessary if the automated install was not used, or if an error occurred during
automated install. Follow the steps carefully! You must be logged in as an administrator to complete the
install.
2. Register assembly
In order to be used by [Link] applications, the task’s assembly (DLL) must be registered in the Global
Assembly Cache (GAC) on the Web server that will run the [Link] web application or Manager.
To register the assembly in the GAC:
a) Open two copies of Windows Explorer.
b) In the first Windows Explorer, navigate to C:\Windows\Assembly (or C:\WINNT\Assembly).
c) In the second Windows Explorer, navigate to the folder where you installed the task files in step
one above.
d) Drag the DLL file for the task ([Link]) from the second window into the Assembly
folder in the first window
location of DLL is “M:\ArcGISServer\Data\CustomTasks\SelectToolTask\ [Link]”
e) Verify that the assembly appears in the Assembly folder by scrolling down and locating its name.
It will not have its .dll extension in this list.
3. Add to Visual Studio toolbox
You must manually add the Task to the Visual Studio (or Visual Web Developer Express) toolbox in order
to be able to drag and drop it onto a page. You could add the task manually in the code for the page, but
having it in the Toolbox makes things much easier.
To add the task to the Visual Studio toolbox:
a) Open Visual Studio 2005 (or Visual Web Developer Express 2005).
b) Open any .aspx page (by opening/creating a website if necessary). This will display the Toolbox
with tools available for [Link] pages. By default the Toolbox appears along the left edge of Visual
Studio.
c) Optional: create a new toolbox group to contain the task. If you skip this step, you will need to
add the task to an existing group (e.g., the General group). To add a group, right-click on the Toolbox
where you want to add the group, and choose Add Tab. The new tab is added with the cursor placed to
enable typing a name. Enter a name, such as Custom Tasks, and hit the Enter key.
d) In the desired toolbox group (e.g., Custom Tasks or General), right-click and choose Choose
Items… The Choose Toolbox Items dialog opens. In this dialog, click Browse, and in the Open dialog,
navigate to the folder where you installed the files in step one above. Highlight the task DLL file
(SelectToolTask) and click Open.
e) The Open dialog closes and the task name is added to the Choose Toolbox Items dialog, and is
checked on. Leave the checkbox checked, and click OK to dismiss the dialog.
f) The task is added to the Toolbox in the group chosen. You can now add the task to any Web ADF
page.
Known Issues
• If ArcIMS was previously installed but subsequently uninstalled, the installer may display an
error message when installing the SelectToolTask, when the option to install into Manager is checked
on. This message may be ignored. To prevent this message from appearing, use the Registry Editor
(Start-Run-regedit) to go to the HKLM/SOFTWARE/ESRI/ARCIMS/9.2 key, and set the ManagerInstalled
value to FALSE.
• In Visual Studio 2005, the task web control is added to a new toolbox tab (group), rather than to
any existing tab. This is a requirement for uninstalling the toolbar via Add/Remove Programs, as it is only
possible to remove entire toolbox tab. You can move the task to another group and add/remove tabs as
desired.
• Task windows (floating panels) do not take the styles specified in the theme (skin) for the
website. A workaround is to add a tag in the [Link] file within the Theme folder used by the web
application. For more information on themes, see the Developer Help for ArcGIS.
• When the user chooses "Run task again", the tool used previously doesn't get activated (stays at
current tool).
• In Visual Studio design mode, the task’s “Set selectable layers” function may not display layers
after changing the map resource items. Workaround is to delete and re-add the task to the page.
Revisions
• 15 June 2007: fixed issue where using the identify tool (in Web Mapping Application) would
hang the web application when the SelectToolTask is added.
• 16 July 2007: compiled task and installer with base 9.2 version instead of any service packs, so
should work with any level of 9.2 .
• 7 September 2007: added closing point to circle and polygon creation in [Link].
• 31 December 31, 2007: modified GetTaskResultsControls in [Link] so a custom task results
container does not throw exception.
Possible Future Enhancements
• May be better to show only one tool at a time, with a drop-down to choose current tool
• Enable administrator to limit the tools available to user
• Change cursor depending on tool type
• Include “Table” hyperlink in task results to display attributes as a table in floating panel