Select to view content in your preferred language

Setting Pop-up windows in the map

3927
32
Jump to solution
06-06-2012 01:46 AM
IkerBerasaluce
New Contributor III
Hello,
I'm not sure if this thread belongs in this forum, but since I can't find the correct one and I'm using the silverlight API in my development I will post it here. If this isn't the correct forum please tell me which is, thank you.
I am trying to use the code sample for Web Map Dynamic Service Popups (http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#WebMapDynamicServicePopups). My problem is that the popup templates property in the dynamic layer is not enabled, so it shows the pop up window (with a little change in the code) but none of the information.
I tried enabling the pop up info using this help guide (http://help.arcgis.com/en/arcgisonline/help/index.html#/Configuring_pop_up_windows/010q0000004m00000...) and setting them is quite straitforward in the arcgis.com map (http://www.arcgis.com/home/webmap/viewer.html) but I can't save the chnages in my service.
I'm not sure if this is the right path or if I have to set the pop ups while creating the map, before I upload it to my server.

Thanks for your help.
0 Kudos
32 Replies
BarraLoubna
New Contributor
I'm still waiting a response from you

Thank you.
0 Kudos
JenniferNery
Esri Regular Contributor
If you want all the fields to show in FeatureLayer MapTip, you can use the following code.
   <esri:FeatureLayer ID="MyLayer" OutFields="*"
          Url="yourServiceUrl">
    <esri:FeatureLayer.MapTip>
     <Grid>
      <Grid.ColumnDefinitions>
       <ColumnDefinition Width="Auto"/>
       <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <ItemsControl ItemsSource="{Binding Keys}" Grid.Column="0" />
      <ItemsControl ItemsSource="{Binding Values}" Grid.Column="1" />
     </Grid>
    </esri:FeatureLayer.MapTip>
   </esri:FeatureLayer>
0 Kudos
BarraLoubna
New Contributor
Hi jennifer, thank you so much for your answer,

Yes I had already tried it and it work, but that's not what I want,
I want when I'd click on a layer I can visualized the attribute information in a window like MapTip of Toolkit_Control and I would like to do this for more than 50 FeatureLayers, so I do not redo the code 50 times for every FeatureLayer, I want something for the Groupe Layer and when i click in the map, not a hover ove.
0 Kudos
BarraLoubna
New Contributor
Hello, I managed to make the sample "Identify" from API Silverlight  in my application with a service that contains several layers:

Code:

IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest...../Monde/MapServer")

But in my application, I would be obliged to work with multiple services and each service contains a single layer, for example, to display their attribute table, then when I wanted to test the tools with a service that contains a single layer, it does not work:

Example of Feature Layer: Code:


IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/CENTRALITE_Administration_Etat/MapServer/2")


So what to do in case I want the Identify fonction on all services that I declared in my Group Layer?

Please help me if you have ideas.
0 Kudos
JoeHershman
MVP Regular Contributor
Hello, I managed to make the sample "Identify" from API Silverlight  in my application with a service that contains several layers:

Code:

IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest...../Monde/MapServer")

But in my application, I would be obliged to work with multiple services and each service contains a single layer, for example, to display their attribute table, then when I wanted to test the tools with a service that contains a single layer, it does not work:

Example of Feature Layer: Code:


IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/CENTRALITE_Administration_Etat/MapServer/2")


So what to do in case I want the Identify fonction on all services that I declared in my Group Layer?

Please help me if you have ideas.


The IdentifyParameters object that you use with the IdentifyTask::ExecuteAsynch methods has a LayerIds property which is a List<int> and this defines which layers to use in the Identify task

    parameters.LayerIds.Add(2);
    identifyTask.ExecuteAsynch(parameters)



Would return only features from the layer with LayerId=2.


Hope that helps,
-Joe
Thanks,
-Joe
0 Kudos
BarraLoubna
New Contributor
Maybe I had asked a wrong question , I'll explain, I used the code of Samples "Identify" and it's work good  with a service that contains several layers, but what I want is how to declare services that contain  a single layer in a service.

and i tried to display the code with  a service that contains a single layer and its not working. how and where i must declare my service.

Code:

private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint;

            ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
            {
                Geometry = clickPoint,
                MapExtent = MyMap.Extent,
                Width = (int)MyMap.ActualWidth,
                Height = (int)MyMap.ActualHeight,
                LayerOption = LayerOption.visible,
                SpatialReference = MyMap.SpatialReference,
   
            };

            IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/...../Monde/MapServer")
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);
  

            GraphicsLayer graphicsLayer = MyMap.Layers["Communes_Luxembourg3"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();
            ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
            {
                Geometry = clickPoint,
                Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };
            graphicsLayer.Graphics.Add(graphic);
        }

        public void ShowFeatures(List<IdentifyResult> results)
        {
            _dataItems = new List<DataItem>();

            if (results != null && results.Count > 0)
            {
                IdentifyComboBox.Items.Clear();
                foreach (IdentifyResult result in results)
                {
                    Graphic feature = result.Feature;
                    string title = result.Value.ToString() + " (" + result.LayerName + ")";
                    _dataItems.Add(new DataItem()
                    {
                        Title = title,
                        Data = feature.Attributes
                    });
                    IdentifyComboBox.Items.Add(title);
                }
                IdentifyComboBox.SelectedIndex = 0;
            }
        }

        void cb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = IdentifyComboBox.SelectedIndex;
            if (index > -1)
                IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data;
        }

        private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
        {
            IdentifyDetailsDataGrid.ItemsSource = null;

            if (args.IdentifyResults != null && args.IdentifyResults.Count > 0)
            {
                IdentifyResultsPanel.Visibility = Visibility.Visible;

                ShowFeatures(args.IdentifyResults);
            }
            else
            {
                IdentifyComboBox.Items.Clear();
                IdentifyComboBox.UpdateLayout();

                IdentifyResultsPanel.Visibility = Visibility.Collapsed;
            }
        }

        public class DataItem
        {
            public string Title { get; set; }
            public IDictionary<string, object> Data { get; set; }
        }

        void IdentifyTask_Failed(object sender, TaskFailedEventArgs e)
        {
            MessageBox.Show("Identify failed. Error: " + e.Error);
        }
0 Kudos
JoeHershman
MVP Regular Contributor
In your code you setup your IdentifyParameters as such:

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

            IdentifyParameters identifyParams = new IdentifyParameters()
                                                    {
                                                        Geometry = clickPoint,
                                                        MapExtent = MyMap.Extent,
                                                        Width = (int) MyMap.ActualWidth,
                                                        Height = (int) MyMap.ActualHeight,
                                                        LayerOption = LayerOption.visible,
                                                        SpatialReference = MyMap.SpatialReference,
                                                    };

            IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/...../Monde/MapServer")
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);
        }


In this code you set the Identify task to return values for all visible layers because LayerOption = LayerOption.visible.

If instead you setup the parameters like this


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

            IdentifyParameters identifyParams = new IdentifyParameters()
                                                    {
                                                        Geometry = clickPoint,
                                                        MapExtent = MyMap.Extent,
                                                        Width = (int) MyMap.ActualWidth,
                                                        Height = (int) MyMap.ActualHeight,
                                                        SpatialReference = MyMap.SpatialReference,
                                                    };

            identifyParams.LayerIds.Add(2);


            IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/...../Monde/MapServer")
            identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;
            identifyTask.ExecuteAsync(identifyParams);
        }


Where instead of setting a value for LayerOptions like in the first example you add Ids to the LayerIds collection


         identifyParams.LayerIds.Add(2);
 


Now when the Identify task runs it will only search fro result from LayerId = 2.  This way you can use a service with many layers but only return identify results from one (or any subset), which seems to be what you want to do

Hope that helps
-Joe
Thanks,
-Joe
0 Kudos
BarraLoubna
New Contributor
Hello, thank you four your help,

I just tried what you said and it works great. but in my case, I have an application that is aimed at a general public, thus:

1 - Part Layer option = LayerOption.visible ==>  for me it's a good solution,     the Identify tool executes on the visible layers ...
2 - Now for my  services, the service that I used above is only an example. my services are  FeatureLayer separatly, i must use more then 20 FeatureLayer separatly,
a part of my service:

<esri:Map.Layers>
  
   <esri1:ArcGISTiledMapServiceLayer  ID="StreetMapLayer"
    Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
   
   <esri1:GroupLayer x:Name="GroupeLayer" ID="Bloomfield Hills" >
   
    <esri1:ArcGISDynamicMapServiceLayer ID="Parcels"
     Url="http://romulus/ArcGIS/rest/services/Limites/Monde/MapServer"/>
       
    <esri1:GroupLayer ID="Landuse Planning">
                
     <esri1:FeatureLayer ID="Points of Interest" Mode="OnDemand"
      Url="http://romulus/ArcGIS/rest/services/Communes_Luxembourg/MapServer"/>                    
    
    
     <esri1:FeatureLayer ID="Linear Features" Mode="OnDemand" Visible="False"
      Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/LandusePlanning/M..." />
                    
    
     <esri1:FeatureLayer ID="Planning Areas" Mode="OnDemand" Visible="False"
      Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/LandusePlanning/M..."/>
    
     <esri1:FeatureLayer ID="Communes_Luxembourg3"
      Url="http://romulus/ArcGIS/rest/services/CENTRALITE_Administration_Etat/MapServer/2">
      <esri1:FeatureLayer.OutFields>
       <sys:String>*</sys:String>
      </esri1:FeatureLayer.OutFields>
           
     </esri1:FeatureLayer>
    
     <esri1:FeatureLayer ID="Axeroute_Luxembourg"  Renderer="{StaticResource MySimplePointRenderer}"
      Url="http://romulus/ArcGIS/rest/services/Axeroute_Luxembourg/MapServer/0">
     
      <esri1:FeatureLayer.OutFields>
       <sys:String>*</sys:String>
      </esri1:FeatureLayer.OutFields>
     
     </esri1:FeatureLayer>
    
     <esri1:FeatureLayer ID="California"     
      Url="http://romulus/ArcGIS/rest/services/Limites/Pays/MapServer">
      <esri1:FeatureLayer.OutFields>
       <sys:String>*</sys:String>
      </esri1:FeatureLayer.OutFields>
     
     </esri1:FeatureLayer>
    
    </esri1:GroupLayer>
 
   </esri1:GroupLayer>
  
         
  </esri:Map.Layers>
  </esri1:Map>




And when I do what you told me on one of these FeatureLayer, its not working.

Now I want to know how I will do for the Identify tool works on all my FeatureLayer or for GroupeLayer, I must declared them separatly in c #?
  like this:


IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/CENTRALITE_Administration_Etat/MapServer/2")
GraphicsLayer graphicsLayer = MyMap.Layers["Communes_Luxembourg3"] as GraphicsLayer;




IdentifyTask identifyTask = new IdentifyTask("http://romulus/ArcGIS/rest/services/Axeroute_Luxembourg/MapServer/0");
GraphicsLayer graphicsLayer = MyMap.Layers["Axeroute_Luxembourg"] as GraphicsLayer;

..........for all FeatureLayer???????

thank you for your help.
0 Kudos
BarraLoubna
New Contributor
[ATTACH=CONFIG]15165[/ATTACH]

This is my interface, I use  separate FeatureLayer so I can appear the attribute table, download content "with id Layer"and make the zoom to layer, the Services contain a single layer separate from a service with  URLs completely different
0 Kudos
JoeHershman
MVP Regular Contributor
I do not believe the Identify task works with FeatureLayers, Identify operation is supported only with MapServices.  If you enter the Url you are using into a browser and go to the bottom of the page you will see operations that are supported by that Rest service Url.

The general thinking behind the Identify task is to do a quick spatial search for features in multiple layers based on a location.  It is along the lines of the Identify tool in ArcMap.

If you have numerous FeatureLayers you could run an Identify on every service that the FeatureLayers are part of passing in the LayerIds of the Layers you use in that Service.  You would not need to do an Identify for every FeatureLayer, but you would have to do one for each of the services that contain your FeatureLayers (e.g. one for each of these...)

     http://romulus/ArcGIS/rest/services/Axeroute_Luxembourg/MapServer
     http://romulus/ArcGIS/rest/services/CENTRALITE_Administration_Etat/MapServer


Passing in the appropriate LayerIds as in my earlier post.

If your goal is to simplify the code in your Silverlight application you might want to look into creating a SOE or Geoprocessing task that does the work on the server with one call from your client.
Thanks,
-Joe
0 Kudos