How to identify features using the Common Data Source API


Summary This sample demonstrates how to use the generic Common Data Source API interfaces in the Web ADF to identify features in multiple layers, in a map resource.

Each feature layer is identified to determine if it contains features that intersect a point at -110, 35 decimal degrees. A buffer tolerance is also provided (3 pixels) to account for user-error when using the identify operation with a map. The buffer tolerance is converted to map units using map image size and extent. Note that the map resource type is non-specific, therefore any data source that supports queries can be used (e.g. ArcIMS, ArcGIS Server). An initial test for query support is included in the sample. The results for the Identify method are returned in an array of standard .NET DataTables (System.Data.DataTable). Each queryable layer (referenced via the string array "layerIDs" in the sample) that contains features intersecting the identify tolerance is included as a DataTable in the DataTable array.
[C#]
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisFunctionality in
    Map1.GetFunctionalities())
{
    ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisResource =
        gisFunctionality.Resource;
    bool supported = gisResource.SupportsFunctionality(typeof
        (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));

    if (supported)
    {
        ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality queryFunctionality = 
            (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)
            gisResource.CreateFunctionality(typeof
            (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);

        string[] layerIDs = null;
        string[] layerNames = null;
        queryFunctionality.GetQueryableLayers(null, out layerIDs, out layerNames);

        ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = new
            ESRI.ArcGIS.ADF.Web.Geometry.Point( - 110, 35);

        int pixelTolerance = 3;

        System.Data.DataTable[] identifyResultsDataTableArray =
            queryFunctionality.Identify(gisFunctionality.Name, adfPoint,
            pixelTolerance, ESRI.ArcGIS.ADF.Web.IdentifyOption.AllLayers, layerIDs);
    }
}
[VB.NET]
For Each gisFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality In Map1.GetFunctionalities()
    Dim gisResource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = gisFunctionality.Resource
    Dim supported As Boolean = gisResource.SupportsFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality))
    
    If supported Then
        Dim queryFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality = CType(gisResource.CreateFunctionality (GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), Nothing), ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)
        
        Dim layerIDs As String() = Nothing
        Dim layerNames As String() = Nothing
        queryFunctionality.GetQueryableLayers(Nothing, layerIDs, layerNames)
        
        Dim adfPoint As ESRI.ArcGIS.ADF.Web.Geometry.Point = New ESRI.ArcGIS.ADF.Web.Geometry.Point( -110, 35)
        
        Dim pixelTolerance As Integer = 3
        
        Dim identifyResultsDataTableArray As System.Data.DataTable() = queryFunctionality.Identify(gisFunctionality.Name, adfPoint, pixelTolerance, ESRI.ArcGIS.ADF.Web.IdentifyOption.AllLayers, layerIDs)
    End If
Next gisFunctionality






Additional Requirements
  • The sample assumes that a Map (named Map1) is available in the current scope.