In this post, Tom Brenneman and Rex Hansen share a control they created that allows you to automatically zoom to the results of a .Net Web ADF task.
This control, called ZoomToResults, enables you to automatically zoom to the result set returned from a task instead of requiring you to navigate through tree-view results in a standard TaskResults control. By default, this control is not visible at runtime. It is designed to simply zoom to the result set in the map if the number of features returned is less than the MaxResultsForMapZoom property. You will need to add this control to a task’s TaskResultsContainers collection to take advantage of these features. Note that this control must be listed before any other container in the collection (e.g. an out-of-the-box TaskResults control). This control was built with version 9.2, Service Pack 3 of the .Net Web ADF.
Follow these steps to use the control in your application.
- In Visual Studio, right click in the Toolbox and click Choose Items.
- Click Browse and navigate to ZoomToResults.dll and click OK.
- Drag the ZoomToResults control onto your web page.
- Set the following properties for ZoomToResults control:
MaxResultsForAutoSelect – this is the maximum result set that will be selected. The results will only be selected if a result set contains this value or less. Set this property to 0 to disable the auto selection capability.
MaxResultsForMapZoom – this is the maximum result set that will be zoomed to. The map will only be zoomed to the result set if it is less than or equal to this value. Set this property to 0 to disable the auto zoom capability.
MinWidthOfZoom – this is the minimum width (or height actually) in map units of the extent rectangle that will be zoomed to. This is particularly useful if the result set is a single point or a very small feature. In this case you could set the minimum extent that the map will zoom to. If you are working with geographic data you may want to make this significantly smaller than the default of 10.
ZoomExtentExpansionPercent – this is the expansion percentage around the extent of the result set for the map to zoom to. This is useful for defining a margin around the extent of features returned in a result set.
DisplayTaskResult – display task results like an out-of-the-box TaskResults control. By default, this property is false.
ShowTaskActivityIndicator – display activity indicator when a task is processing, like an out-of-the-box TaskResults control. By default, this property is false.
- To associate this container with a task, at design-time in design view click on the smart tag on the task and select Choose Task Results container.
- Click Add. Set the Name property of the new BuddyControl to the name of the ZoomToResult control (e.g. ZoomtoResults1).
- In the BuddyControl Collection Editor click the up arrow to move the ZoomToResults buddy control to the top of the list.
- Click OK to dismiss the BuddyControl Collection Editor.
- Try out the app!
Download the 9.2 control (The compressed folder contains the code with extensive comments from Tom and Rex, as well as a Readme file with the above instructions.)
Updated download for ArcGIS Server 9.3