Setting Pop-up windows in the map

3766
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
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
but I can't save the chnages in my service.


For this particular aspect of your question, note that the arcgis.com viewer doesn't allow to save configuation (popoup, symbology...) at the service level. It is only possible at the map level.

To save at the service level, you can use ArcGIS Online Explorer.

View solution in original post

0 Kudos
32 Replies
JenniferNery
Esri Regular Contributor
You are talking about creating pop-ups for map service in webmap that you are consuming in Silverlight App? I think this is the right forum: http://forums.arcgis.com/forums/30-ArcGIS-Online. But it looks like you found the correct resource page.

You also probably want to look at this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#WebMapDynamicServicePopups, which consumes this webmap http://www.arcgis.com/home/webmap/viewer.html?webmap=fd7fb514579f4422ab2698f47a7d4a46. The popup information is actually saved in the webmap JSON: http://www.arcgis.com/sharing/content/items/fd7fb514579f4422ab2698f47a7d4a46/data?f=pjson. I don't know if that answers your question but hopefully the right forum will be more helpful 🙂
0 Kudos
DominiqueBroux
Esri Frequent Contributor
but I can't save the chnages in my service.


For this particular aspect of your question, note that the arcgis.com viewer doesn't allow to save configuation (popoup, symbology...) at the service level. It is only possible at the map level.

To save at the service level, you can use ArcGIS Online Explorer.
0 Kudos
BarraLoubna
New Contributor
Hello Dominique BROUX and Jennifer Nery,

I want to create a popup so that it can retrieve information about the feature attribute from attribute table of my layers. I tried this sample : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm WebMapTiledServicePopups    in microsoft Blend , but when I execute it  nothing happens when I click a feature and not give me an error message ... I do not know what i must do, please kindly help me, this is very urgent
0 Kudos
BarraLoubna
New Contributor
this is my code :

in XAML  :

<esri1:Map x:Name="MyMap" ExtentChanged="MyMap_ExtentChanged" Margin="274,23,14,160" VerticalContentAlignment="Stretch"
     HorizontalContentAlignment="Stretch" Padding="0" Grid.Row="1" IsLogoVisible="False" WrapAround="True"  MouseClick="MyMap_MouseClick" >
  
  
  
   <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"
      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/Monde/MapServer/1">
      <esri1:FeatureLayer.OutFields>
       <sys:String>*</sys:String>
      </esri1:FeatureLayer.OutFields>
     
     </esri1:FeatureLayer>
    
    </esri1:GroupLayer>
 
   </esri1:GroupLayer>
    
    <esri:GraphicsLayer ID="IdentifyIconGraphicsLayer" />
      <esri:GraphicsLayer ID="ResultsGraphicsLayer" />
  </esri1:Map>


<esri1:InfoWindow x:Name="MyInfoWindow"
                         Padding="2"
                         CornerRadius="10"                       
                         Map="{Binding ElementName=MyMap}" >
            <esri1:InfoWindow.Background>
                <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188">
                    <GradientStop Color="#FFD1DFF2"/>
                    <GradientStop Color="#FFAAAAAA" Offset="0.946"/>
                </LinearGradientBrush>
            </esri1:InfoWindow.Background>
        </esri1:InfoWindow>


in c# :

InitializeComponent();
  
          Document webMap = new Document();
            webMap.GetMapCompleted += webMap_GetMapCompleted;
            webMap.GetMapAsync("0e8aa0cc8dcb47d3b9a46e3c6c7c0f8f");




        

void webMap_GetMapCompleted(object sender, GetMapCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                MyMap.Extent = e.Map.Extent;

                LayerCollection layerCollection = new LayerCollection();
                foreach (Layer layer in e.Map.Layers)
                    layerCollection.Add(layer);

                GraphicsLayer selectedGraphics = new GraphicsLayer()
                {
                    RendererTakesPrecedence = false,
                    ID = "MySelectionGraphicsLayer"
                };
                layerCollection.Add(selectedGraphics);

                e.Map.Layers.Clear();
                MyMap.Layers = layerCollection;
            }
        }

        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            GraphicsLayer glayer = MyMap.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;
            glayer.Graphics.Clear();

            MyInfoWindow.IsOpen = false;

            double mapScale = (MyMap.Resolution * 39.3700787) * 96;

            ArcGISTiledMapServiceLayer alayer = null;
            DataTemplate dt = null;
            int layid = 0;

            foreach (Layer layer in MyMap.Layers)
            {
                if (layer.GetValue(Document.PopupTemplatesProperty) != null)
                {
                    alayer = layer as ArcGISTiledMapServiceLayer;
                    IDictionary<int, DataTemplate> idict = layer.GetValue(Document.PopupTemplatesProperty) as IDictionary<int, DataTemplate>;

                    foreach (LayerInfo linfo in alayer.Layers)
                    {
                        if (((mapScale > linfo.MaxScale // in scale range
                            && mapScale < linfo.MinScale) ||
                            (linfo.MaxScale == 0.0 // no scale dependency
                            && linfo.MinScale == 0.0) ||
                            (mapScale > linfo.MaxScale // minscale = 0.0 = infinity
                            && linfo.MinScale == 0.0)) &&
                            idict.ContainsKey(linfo.ID)) // id present in dictionary
                        {
                            layid = linfo.ID;
                            dt = idict[linfo.ID];
                            break;
                        }
                    }
                }
            }

            if (dt != null)
            {
   
    QueryTask qt = new QueryTask(string.Format("{0}/{1}", alayer.Url, layid));
                qt.ExecuteCompleted += (s, qe) =>
                {
                    if (qe.FeatureSet.Features.Count > 0)
                    {
                        Graphic g = qe.FeatureSet.Features[0];
                        MyInfoWindow.Anchor = e.MapPoint;
                        MyInfoWindow.ContentTemplate = dt;
                        MyInfoWindow.Content = g.Attributes;
                        MyInfoWindow.IsOpen = true;

                        SolidColorBrush symbolColor = new SolidColorBrush(Colors.Cyan);

                        if (g.Geometry is Polygon || g.Geometry is Envelope)
                        {
                            g.Symbol = new SimpleFillSymbol()
                            {
                                BorderBrush = symbolColor,
                                BorderThickness = 2
                            };
                        }
                        else if (g.Geometry is Polyline)
                        {
                            g.Symbol = new SimpleLineSymbol()
                            {
                                Color = symbolColor
                            };
                        }
                        else // Point
                        {
                            g.Symbol = new SimpleMarkerSymbol()
                            {
                                Color = symbolColor,
                                Size = 12
                            };
                        }
                        glayer.Graphics.Add(g);
                    }
                };

                ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
                query.Geometry = e.MapPoint;
                query.OutSpatialReference = MyMap.SpatialReference;
                query.OutFields.Add("*");
                query.ReturnGeometry = true;

                qt.ExecuteAsync(query);
            }
        }
0 Kudos
BarraLoubna
New Contributor
Please, I am not strong in programing, I need help, please
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Since you create your feature layers in XAML, you can define your maptips in XAML as well without any c# code.
There are samples here :

0 Kudos
BarraLoubna
New Contributor
I managed to do a feature on the MapTips layer as this example:

http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerMapTips

Now I want to know how to do it on all the layers I have and I wish I made �??�??them appear all the fields in each layer as result of this example:

[url]http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MapTipWidget.

Without specification of a one field or two, I want to make �??�??them appear all the fields of the attribute on which i click.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Likely you don't need the cluster that is set in the sample --> remove it (else it's probably a casing error :   FeatureLayer .Clusterer)
0 Kudos
BarraLoubna
New Contributor
Finally, I am pleased that you are there Dominique.

I just  remove the cluster and it work, now I asked another question is how to make appear the information of an attribute from attribute table and make it for all my layers, not just a single layer, I want something automatic on group layers and that I made �??�??them appear all the attribute fields.

I hope I explained what I'm trying to do and for more precision, I would like when I click on an attribute that makes them appear to in a window as the sample of the MapTips Toolkit Controls without the "hover":

http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MapTipWidget

May be as the result of "identify" too, if you click on several different attribute layer, you can pass in the window of an attribute from one layer to another, but not in a large window, in a window like MapTips-Toolkit Controls.

Thank you for your cooperation, your help and time.
0 Kudos