Exemplo n.º 1
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 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);
 }