void helper_GetLayerInfosCompleted(object sender, MapServiceLayerInfoHelper.LayerInfosEventArgs e)
        {
            MapServiceLayerInfoHelper helper   = sender as MapServiceLayerInfoHelper;
            Collection <int>          layerIds = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetIdentifyLayerIds(helper.Layer);

            if ((layerIds != null && layerIds.Count > 0))
            {
                if (e.LayerInfos != null)
                {
                    foreach (LayerInformation item in e.LayerInfos)
                    {
                        if (layerIds.Contains(item.ID))
                        {
                            item.PopUpsEnabled = true;
                        }
                    }
                }
            }
            if (Layer == helper.Layer)//if still the selected layer, update the config layer
            {
                if (e.LayerInfos == null || e.LayerInfos.Count < 1)
                {
                    this.DataContext = null;
                }
                else
                {
                    setMapServiceLayerDataContext(e.LayerInfos);
                }
            }
        }
예제 #2
0
        private void getLayerInfos(Layer layer)
        {
            if (layer == null)
            {
                return;
            }
            string layerUrl = IdentifySupport.GetLayerUrl(layer);

            if (!string.IsNullOrWhiteSpace(layerUrl))
            {
                MapServiceLayerInfoHelper helper = new MapServiceLayerInfoHelper(layerUrl, layer, IdentifySupport.GetLayerProxyUrl(layer));
                helper.GetLayerInfosCompleted += (s, e) =>
                {
                    Collection <LayerInformation> gpResultMapServerLayerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetGPResultMapServerLayerInfos(layer);
                    Collection <LayerInformation> layerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetLayerInfos(layer);
                    if (gpResultMapServerLayerInfos != null)
                    {
                        Collection <int> layerIds = new Collection <int>();
                        foreach (LayerInformation layerInfo in layerInfos)
                        {
                            LayerInformation gpResultMapServerLayerInfo = gpResultMapServerLayerInfos.FirstOrDefault(p => p.ID == layerInfo.ID);
                            if (gpResultMapServerLayerInfo != null)
                            {
                                layerInfo.PopUpsEnabled = gpResultMapServerLayerInfo.PopUpsEnabled;
                                if (!string.IsNullOrEmpty(gpResultMapServerLayerInfo.DisplayField))
                                {
                                    layerInfo.DisplayField = gpResultMapServerLayerInfo.DisplayField;
                                }
                                if (layerInfo.PopUpsEnabled)
                                {
                                    layerIds.Add(layerInfo.ID);
                                }

                                foreach (FieldInfo field in layerInfo.Fields)
                                {
                                    FieldInfo gpField = gpResultMapServerLayerInfo.Fields.FirstOrDefault(p => p.Name == field.Name);
                                    if (gpField != null)
                                    {
                                        field.DisplayName     = gpField.DisplayName;
                                        field.VisibleOnMapTip = gpField.VisibleOnMapTip;
                                    }
                                }
                            }
                        }
                        ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetIdentifyLayerIds(layer, layerIds);
                    }
                };
                helper.GetLayerInfos(null);
            }
        }
 private void bindToMapServiceLayer(Layer layer)
 {
     if (layer == null)
         return;
     Collection<LayerInformation> layerInfos = LayerExtensions.GetLayerInfos(layer);
     if (layerInfos == null || layerInfos.Count < 1)
     {
         string layerUrl = IdentifySupport.GetLayerUrl(layer);
         if (!string.IsNullOrWhiteSpace(layerUrl))
         {
             MapServiceLayerInfoHelper helper = new MapServiceLayerInfoHelper(layerUrl, Layer, IdentifySupport.GetLayerProxyUrl(layer));
             helper.GetLayerInfosCompleted += helper_GetLayerInfosCompleted;
             helper.GetLayerInfos(null);
         }
     }
     else
         setMapServiceLayerDataContext(layerInfos);
 }
        private void bindToMapServiceLayer(Layer layer)
        {
            if (layer == null)
            {
                return;
            }
            Collection <LayerInformation> layerInfos = LayerExtensions.GetLayerInfos(layer);

            if (layerInfos == null || layerInfos.Count < 1)
            {
                string layerUrl = IdentifySupport.GetLayerUrl(layer);
                if (!string.IsNullOrWhiteSpace(layerUrl))
                {
                    MapServiceLayerInfoHelper helper = new MapServiceLayerInfoHelper(layerUrl, Layer, IdentifySupport.GetLayerProxyUrl(layer));
                    helper.GetLayerInfosCompleted += helper_GetLayerInfosCompleted;
                    helper.GetLayerInfos(null);
                }
            }
            else
            {
                setMapServiceLayerDataContext(layerInfos);
            }
        }
        private void getLayerInfos(Layer layer)
        {
            if (layer == null)
                return;
            string layerUrl = IdentifySupport.GetLayerUrl(layer);
            if (!string.IsNullOrWhiteSpace(layerUrl))
            {
                MapServiceLayerInfoHelper helper = new MapServiceLayerInfoHelper(layerUrl, layer, IdentifySupport.GetLayerProxyUrl(layer));
                helper.GetLayerInfosCompleted += (s, e) =>
                {
                    Collection<LayerInformation> gpResultMapServerLayerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetGPResultMapServerLayerInfos(layer);
                    Collection<LayerInformation> layerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetLayerInfos(layer);
                    if (gpResultMapServerLayerInfos != null)
                    {
                        Collection<int> layerIds = new Collection<int>();
                        foreach (LayerInformation layerInfo in layerInfos)
                        {
                            LayerInformation gpResultMapServerLayerInfo = gpResultMapServerLayerInfos.FirstOrDefault(p => p.ID == layerInfo.ID);
                            if (gpResultMapServerLayerInfo != null)
                            {
                                layerInfo.PopUpsEnabled = gpResultMapServerLayerInfo.PopUpsEnabled;
                                if (!string.IsNullOrEmpty(gpResultMapServerLayerInfo.DisplayField)) layerInfo.DisplayField = gpResultMapServerLayerInfo.DisplayField;
                                if (layerInfo.PopUpsEnabled) layerIds.Add(layerInfo.ID);

                                foreach (FieldInfo field in layerInfo.Fields)
                                {
                                    FieldInfo gpField = gpResultMapServerLayerInfo.Fields.FirstOrDefault(p => p.Name == field.Name);
                                    if (gpField != null)
                                    {
                                        field.DisplayName = gpField.DisplayName;
                                        field.VisibleOnMapTip = gpField.VisibleOnMapTip;
                                    }
                                }
                            }
                        }
                        ESRI.ArcGIS.Mapping.Core.LayerExtensions.SetIdentifyLayerIds(layer, layerIds);

                    }
                };
                helper.GetLayerInfos(null);
            }
        }
 void helper_GetLayerInfosCompleted(object sender, MapServiceLayerInfoHelper.LayerInfosEventArgs e)
 {
     MapServiceLayerInfoHelper helper = sender as MapServiceLayerInfoHelper;
     Collection<int> layerIds = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetIdentifyLayerIds(helper.Layer);
     if ((layerIds != null && layerIds.Count > 0))
     {
         if (e.LayerInfos != null)
         {
             foreach (LayerInformation item in e.LayerInfos)
             {
                 if (layerIds.Contains(item.ID))
                     item.PopUpsEnabled = true;
             }
         }
     }
     if (Layer == helper.Layer)//if still the selected layer, update the config layer
     {
         if (e.LayerInfos == null || e.LayerInfos.Count < 1)
             this.DataContext = null;
         else
             setMapServiceLayerDataContext(e.LayerInfos);
     }
 }