IdentifyTask and Multiple map services

3300
14
02-17-2011 10:06 AM
AngelGonzalez
Occasional Contributor II
How would you go about using the IdentifyTasK with multiple map service? Sample code wouild be appreciate.
0 Kudos
14 Replies
SantoshV
New Contributor II
Hi thanks for your reply..
       I have gone through the sample but it is same as the above code as it also iterates through every service
My problem is that I have about 10 services running and iterating through 10 services takes more time so my identify tool works slow, populating the layername from the results into the combobox take a long time about2 seconds for each ltem

my code goes like this
private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{
           // create identifyParams object
            IdentifyParameters identifyParams = new IdentifyParameters()
            { 
                Geometry = mapPoint,
                //Tolerance = 50,
                MapExtent = mainPage.map.Extent,
                Width = (int)mainPage.map.ActualWidth,
                Height = (int)mainPage.map.ActualHeight,
                LayerOption = LayerOption.visible,
                SpatialReference = mainPage.map.SpatialReference
            };
            
            // store all the available services in to myMapService stack
            storeMapServices();
            identifyTask.Url = myMapService.Pop();
            identifyTask.ExecuteAsync(identifyParams, identifyParams);
  }


void identifyTask_ExecuteCompleted(object sender, IdentifyEventArgs e)
{
              if (e.IdentifyResults != null && e.IdentifyResults.Count > 0)
            {
                boolNeedReset = false;

                //get Layerkeyfield and add identify results to dictionary
                ShowFeatures(e.IdentifyResults);                
            }
            if (tempInt < 2)
            {
                identifyTask.Url = myMapService.Pop();      
                IdentifyParameters identifyParams = e.UserState as IdentifyParameters;
                identifyTask.ExecuteAsync(identifyParams, identifyParams);
            }
}


       
public void ShowFeatures(List<IdentifyResult> results)
        {
            int intFeatureCount = 0;

            //Get the Layer Key Field 
            
           DataAccessService.DataAccessServiceClient dataAccessServiceClient = new DataAccessService.DataAccessServiceClient();
           dataAccessServiceClient.getLayerKeyIDAsync(results[0].LayerName);
          dataAccessServiceClient.getLayerKeyIDCompleted += ((s, e) =>
           {
               if (e.Result != string.Empty && e.Result != null)
               {
                   kvpLayerKeyField.Add(results[0].LayerName, e.Result);
                   foreach (IdentifyResult result in results)
                   {
                       if (!kvpIdentifyResults.Keys.Contains(Convert.ToInt32(results[intFeatureCount].Feature.Attributes[e.Result])))
                       {
                           kvpIdentifyResults.Add(Convert.ToInt32(results[intFeatureCount].Feature.Attributes[e.Result]), results[intFeatureCount].LayerName);
                           intFeatureCount++;
                       }
                   }
                   //add identified layernames to combobox
                   IdentifyComboBox.Items.Add(results[0].LayerName);
               }
           }); 
}
            
        


Is there any other way to get mouse map pointer clicked element attributes form other then Identifytask?
0 Kudos
DawnBlanchard
New Contributor
Hi,

Thanks for the code.  I have a question.  Where does the code set the IdentifyButtonClicked, IdentifyResultsPanelVisible, and _needReset?  Would you please show the code behind the button?

Thanks in advance!
0 Kudos
AngelGonzalez
Occasional Contributor II
Hi Dawn,
Below is the ButtonIdentify_Clicked code. By clicking on this button the IdentifyStackPanel will either be turned on or off as well as the initial setting of the IdentifyResultsPanel Visibility. The code I listed above will then update the status/value of the IdentifyResultsPanel & _needReset.

Hope this help



private void ButtonIdentify_Click(object sender, RoutedEventArgs e)
        {
            MyDrawObject.IsEnabled = false;
            if (IdentifyButtonClicked == false)
            {
                // Make IdentifyStackPAnel visible
                IdentifyButtonClicked = true;
                IdentifyStackPanel.Visibility = Visibility.Visible;
            }
            else
            {
                // Make IdentifyStackPanel not visibile, clear identify graphic, clear IdentifyComboBox & collapse
                IdentifyButtonClicked = false;
                IdentifyStackPanel.Visibility = Visibility.Collapsed;
                GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.ClearGraphics();

                IdentifyComboBox.Items.Clear();
                IdentifyComboBox.UpdateLayout();

                IdentifyResultsPanel.Visibility = Visibility.Collapsed;

                MyMap.Cursor = Cursors.Arrow;
            }
        }
0 Kudos
BarraLoubna
New Contributor
Hello, thank you very much for your suggetion

I tried what you suggested but it gives me a message errors like:
the name 'identifyTask_Failed' does not exist in the current context.
the name 'MapRow' does not exist in the current context.
the name 'e' does not exist in the current context.
....


On the other hand, I had managed to identify my attributes depending on the sample "query Identify" and use it:

IdentifyTask identifyTask IdentifyTask = new ("http://rom/ArcGIS/rest/services/.../MapServer");



I want when I click that button and I click on the map, the Identify window opens with the information of the attribute.

I managed to combine Identify a button in the toolbar that when I launch the   application, the  Identify window does not opens, until I click the button, it appears, empty

code:
<esri1:ToolbarItem x:Name="Identify" Text="Identify">
<esri1:ToolbarItem.Content>
  <Button  >
   <Image Source="i_identify.png" Stretch="UniformToFill"/>
                                      <i:Interaction.Triggers>
                                          <i:EventTrigger EventName="Click">
                                              <local:ToggleVisibilityAction TargetName="IdentifyBorder">
                                              </local:ToggleVisibilityAction>
      </i:EventTrigger>
                                       </i:Interaction.Triggers>
                </Button>
</esri1:ToolbarItem.Content>
</esri1:ToolbarItem>


what I want is that when I click the button nothing appears until I click on the map, then the Identify window opens with the information ...
0 Kudos
BarraLoubna
New Contributor
I return to post the solution I found,

for  Identify an attribute after I selects the tools and I click on the map, I do:

bool test1 = false;



private void QueryPoint_MouseClick (object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
         {
....

if (test1)
    {
    
   IdentifyGrid.Visibility = Visibility.Visible;
   IdentifyBorder.Visibility = Visibility.Visible;
   IdentifyMap.Visibility = Visibility.Visible;
    }
}



and



private void Identify_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
  {
   this.test1 = !this.test1;
   if (!test1)
    {
    
   IdentifyGrid.Visibility = Visibility.Collapsed;
   IdentifyBorder.Visibility = Visibility.Collapsed;
   IdentifyMap.Visibility = Visibility.Collapsed;
    }
  }

Thank you.
0 Kudos