当前位置: 首页>>代码示例>>C#>>正文


C# FeatureLayer.SetValue方法代码示例

本文整理汇总了C#中FeatureLayer.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayer.SetValue方法的具体用法?C# FeatureLayer.SetValue怎么用?C# FeatureLayer.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FeatureLayer的用法示例。


在下文中一共展示了FeatureLayer.SetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateLayerAsync

        public override void CreateLayerAsync(Resource layerResource, SpatialReference mapSpatialReference, object userState)
        {
            if (layerResource.ResourceType == ResourceType.DatabaseTable)
            {
                featureService = new FeatureService(layerResource.Url);
                featureService.GetFeatureServiceDetailsFailed += (o, e) =>
                {
                    OnCreateLayerFailed(e);
                };
                featureService.GetFeatureServiceDetailsCompleted += (o, e) =>
                {
                    if (e.FeatureServiceInfo == null)
                    {
                        OnCreateLayerFailed(new ESRI.ArcGIS.Mapping.Core.ExceptionEventArgs(new Exception(Resources.Strings.ExceptionUnableToRetrieveLayerDetails), e.UserState));
                        return;
                    }
                    GeometryType GeometryType = GeometryType.Unknown;
                    switch (e.FeatureServiceInfo.GeometryType)
                    {
                        case "esriGeometryPoint":
                            GeometryType = GeometryType.Point;
                            break;
                        case "esriGeometryMultipoint":
                            GeometryType = GeometryType.MultiPoint;
                            break;
                        case "esriGeometryPolyline":
                            GeometryType = GeometryType.Polyline;
                            break;
                        case "esriGeometryPolygon":
                            GeometryType = GeometryType.Polygon;
                            break;
                    }
                    FeatureLayer newFeatureLayer = new FeatureLayer()
                    {
                        Url = featureService.Uri,
                        ID = Guid.NewGuid().ToString("N"),
                        Mode = FeatureLayer.QueryMode.OnDemand,
                        Renderer = new ESRI.ArcGIS.Mapping.Core.Symbols.HiddenRenderer()
                    };        
                    newFeatureLayer.SetValue(MapApplication.LayerNameProperty, layerResource.DisplayName);
                    newFeatureLayer.SetValue(Core.LayerExtensions.GeometryTypeProperty, GeometryType);
                    newFeatureLayer.SetValue(Core.LayerExtensions.DisplayUrlProperty, layerResource.Url);

                    if (e.FeatureServiceInfo.Fields != null)
                    {
                        Collection<FieldInfo> fields = new Collection<FieldInfo>();
                        foreach (Field field in e.FeatureServiceInfo.Fields)
                        {
                            if (field.DataType == "Microsoft.SqlServer.Types.SqlGeometry" || field.DataType == "esriFieldTypeGeometry")
                                continue;
                            fields.Add(new FieldInfo()
                            {
                                DisplayName = field.Name,
                                FieldType = mapFieldType(field.DataType),
                                Name = field.Name,
                                VisibleInAttributeDisplay = true,
                                VisibleOnMapTip = true,
                            });
                        }
                        newFeatureLayer.SetValue(Core.LayerExtensions.FieldsProperty, fields);
                    }
                    newFeatureLayer.OutFields.Add("*"); // Get all fields at configuration time
                    OnCreateLayerCompleted(new CreateLayerCompletedEventArgs() { Layer = newFeatureLayer, UserState = e.UserState, GeometryType = GeometryType });
                };
                featureService.GetFeatureServiceDetails(userState);
            }
            else
            {
                OnCreateLayerFailed(new ESRI.ArcGIS.Mapping.Core.ExceptionEventArgs(new Exception(string.Format(Resources.Strings.ExceptionCannotCreateLayerForResourceType, layerResource.ResourceType.ToString())), userState));
            }
        }
开发者ID:yulifengwx,项目名称:arcgis-viewer-silverlight,代码行数:71,代码来源:SpatialDataServiceDataSource.cs

示例2: CreateLayerAsync

        public override void CreateLayerAsync(Resource resource, SpatialReference mapSpatialReference, object userState)
        {
            if(resource == null)
                return;

            ESRI.ArcGIS.Client.Layer layer = null;

            switch (resource.ResourceType)
            {
                case ResourceType.MapServer:
                case ResourceType.FeatureServer:
                    {
                        string url = resource.Url;
                        if (resource.ResourceType == ResourceType.FeatureServer)
                        {
                            int i = url.LastIndexOf(string.Format("/{0}", ResourceType.FeatureServer.ToString()));
                            if (i >= 0)
                            {
                                url = url.Remove(i);
                                url = string.Format("{0}/{1}", url, ResourceType.MapServer.ToString());
                            }
                        }

                        _service = ServiceFactory.CreateService(ResourceType.MapServer, url, resource.ProxyUrl);
                        if (_service != null)
                        {
                            _service.ServiceDetailsDownloadFailed += (o, e) =>
                            {
                                OnCreateLayerFailed(e);
                            };
                            _service.ServiceDetailsDownloadCompleted += (o, e) =>
                            {
                                MapService mapService = o as MapService;
                                if (mapService.ServiceInfo == null)
                                {
                                    OnCreateLayerFailed(new ExceptionEventArgs(new Exception(Resources.Strings.ExceptionUnableToRetrieveMapServiceDetails), e.UserState));
                                    return;
                                }

                                if (mapService.ServiceInfo.TileInfo != null && mapService.ServiceInfo.SingleFusedMapCache)
                                {
                                    #region Create tiled layer
                                    if (mapSpatialReference != null && !mapSpatialReference.Equals(mapService.ServiceInfo.SpatialReference))
                                    {
                                        OnCreateLayerFailed(new ExceptionEventArgs(new Exception(Resources.Strings.ExceptionCachedMapServiceSpatialReferenceDoesNotMatch), e.UserState));
                                        return;
                                    }
                                    layer = new ArcGISTiledMapServiceLayer()
                                    {
                                        Url = url,
                                        ProxyURL = getCleanProxyUrl(mapService.ProxyUrl),
                                    };

                                    if (mapService.ServiceInfo.TileInfo.LODs != null)
                                    {
                                        double maxResolution = 0;
                                        double minResolution = 0;
                                        foreach (LODInfo lod in mapService.ServiceInfo.TileInfo.LODs)
                                        {
                                            if (lod.Resolution > maxResolution)
                                                maxResolution = lod.Resolution;
                                            if (minResolution <= 0 || minResolution > lod.Resolution)
                                                minResolution = lod.Resolution;
                                        }
                                        if (maxResolution > 0 )
                                            layer.MaximumResolution = maxResolution * 4;
                                        if (minResolution > 0)
                                            layer.MinimumResolution = minResolution / 4;
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region create dynamic layer
                                    layer = new ArcGISDynamicMapServiceLayer()
                                    {
                                        Url = url,
                                        ProxyURL = getCleanProxyUrl(mapService.ProxyUrl),
                                    };
                                    #endregion
                                }

                                //Set layer's attached properties
                                if (layer != null)
                                {
                                    layer.SetValue(MapApplication.LayerNameProperty, resource.DisplayName);
                                    layer.SetValue(Core.LayerExtensions.DisplayUrlProperty, url);
                                    if (!string.IsNullOrEmpty(resource.ProxyUrl))
                                        Core.LayerExtensions.SetUsesProxy(layer, true);
                                    layer.ID = Guid.NewGuid().ToString("N");
                                }

                                OnCreateLayerCompleted(new CreateLayerCompletedEventArgs() { Layer = layer, UserState = e.UserState });

                            };

                            _service.GetServiceDetails(null);
                        }

                    } break;
//.........这里部分代码省略.........
开发者ID:yulifengwx,项目名称:arcgis-viewer-silverlight,代码行数:101,代码来源:ArcGISServerDataSource.cs

示例3: SetFeatureCollectionJson

 /// <summary>
 /// Sets the stored feature collection JSON for the layer
 /// </summary>
 /// <remarks>
 /// Note that this method has no effect on the bound layer, other than to set the string
 /// value of this property.
 /// </remarks>
 public static void SetFeatureCollectionJson(FeatureLayer obj, string value)
 {
     obj.SetValue(FeatureCollectionJsonProperty, value);
 }
开发者ID:konglingjie,项目名称:arcgis-viewer-silverlight,代码行数:11,代码来源:LayerExtensions.cs

示例4: SetFeatureLayerPropsFromLayerInfo

        private void SetFeatureLayerPropsFromLayerInfo(FeatureLayer fLayer)
        {
            if (fLayer == null || fLayer.LayerInfo == null)
                return;

            if (string.IsNullOrWhiteSpace(LayerExtensions.GetDisplayUrl(fLayer)))
                fLayer.SetValue(LayerExtensions.DisplayUrlProperty, fLayer.Url);

            if (!string.IsNullOrWhiteSpace(fLayer.LayerInfo.DisplayField) &&
                string.IsNullOrWhiteSpace(LayerExtensions.GetDisplayField(fLayer)))
                fLayer.SetValue(LayerExtensions.DisplayFieldProperty, fLayer.LayerInfo.DisplayField);

            if (LayerExtensions.GetGeometryType(fLayer) == GeometryType.Unknown)
            {
                if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Point)
                    fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.Point);
                if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.MultiPoint)
                    fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.MultiPoint);
                else if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Polyline)
                    fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.Polyline);
                else if (fLayer.LayerInfo.GeometryType == ESRI.ArcGIS.Client.Tasks.GeometryType.Polygon)
                    fLayer.SetValue(LayerExtensions.GeometryTypeProperty, GeometryType.Polygon);
            }

            if (fLayer.LayerInfo.Fields != null)
            {
                Collection<FieldInfo> layerFields = LayerExtensions.GetFields(fLayer);
                if (layerFields.Count == 0) // fields not determined yet
                {
                    Collection<FieldInfo> fieldInfos = new Collection<FieldInfo>();
                    foreach (ESRI.ArcGIS.Client.Field field in fLayer.LayerInfo.Fields)
                    {
                        if (FieldHelper.IsFieldFilteredOut(field.Type))
                            continue;

                        FieldInfo f = ESRI.ArcGIS.Mapping.Core.FieldInfo.FieldInfoFromField(fLayer, field);

                        fieldInfos.Add(f);
                    }
                    fLayer.SetValue(LayerExtensions.FieldsProperty, fieldInfos);
                }
            }
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:43,代码来源:Layer.cs

示例5: SetFeatureLayerEditingProperties

        private void SetFeatureLayerEditingProperties(FeatureLayer layer, bool selectedForEditing)
        {
            if (layer == null)
                return;

            layer.DisableClientCaching = selectedForEditing;
            if (selectedForEditing)
            {
                bool popupsOnClick = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetPopUpsOnClick(layer);
                bool newPopupsOnClick = selectedForEditing && SetLayerPopupOnClick;
                if (!popupsOnClick && popupsOnClick != newPopupsOnClick)
                {
                    layer.SetValue(ESRI.ArcGIS.Mapping.Core.LayerExtensions.PopUpsOnClickProperty, newPopupsOnClick);
                    layer.SetValue(ESRI.ArcGIS.Mapping.Core.LayerExtensions.IsMapTipDirtyProperty, true);
                }
            }
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:17,代码来源:EditorConfiguration.cs


注:本文中的FeatureLayer.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。