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


C# FeatureLayer.ClearDisplayCache方法代码示例

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


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

示例1: ChangeUSHighwaysLayerDataConnectionAsync

        private Task ChangeUSHighwaysLayerDataConnectionAsync(FeatureLayer featureLayer, string catalogPath) {
            return QueuedTask.Run(() => {
                CIMDataConnection currentDataConnection = featureLayer.GetDataConnection();

                string connection = System.IO.Path.GetDirectoryName(catalogPath);
                string suffix = System.IO.Path.GetExtension(connection).ToLower();

                WorkspaceFactory wf = WorkspaceFactory.FileGDB;
                if (suffix == ".sde") {
                    wf = WorkspaceFactory.SDE;
                }

                string dataset = System.IO.Path.GetFileName(catalogPath);

                // provide a replace data connection method
                CIMStandardDataConnection updatedDataConnection = new CIMStandardDataConnection() {
                    WorkspaceConnectionString = new Geodatabase(connection).GetConnectionString(),
                    WorkspaceFactory = wf,
                    Dataset = dataset,
                    DatasetType = esriDatasetType.esriDTFeatureClass
                };

                featureLayer.SetDataConnection(updatedDataConnection);

                //For a RDBMS, it might look like this:
                //string connection = "C:\\Work\\temp.sde";
                //Geodatabase sde = new Geodatabase(connection);

                //// provide a replace data connection method
                //CIMStandardDataConnection updatedDataConnection = new CIMStandardDataConnection();
                //updatedDataConnection.WorkspaceConnectionString = sde.GetConnectionString();
                //updatedDataConnection.WorkspaceFactory = WorkspaceFactory.SDE;
                //updatedDataConnection.Dataset = "vtest.usa.states";
                //updatedDataConnection.DatasetType = esriDatasetType.esriDTFeatureClass;



                //// Alternatively, use Layer.FindAndReplaceWorkspacePath()
                ////Note: this will not allow changing the dataset name or workspace type
                ////
                ////string connection = "C:\\Work\\temp.sde";
                ////Geodatabase sde = new Geodatabase(connection);
                ////featureLayer.FindAndReplaceWorkspacePath(((CIMStandardDataConnection)currentDataConnection).WorkspaceConnectionString, 
                ////                        sde.GetConnectionString(), true);


                //////////////////////////////////////////////
                ////Please Read
                ////
                //ok, so at this point we have a couple of bugs at 1.1 AND 1.2.....
                //
                //#1: if you switched to a Datasource that invalidates the Renderer, the Renderer does
                //not get invalidated in the UI
                //(eg You had a UniqueValueRenderer on a Field called "CATEGORY", the new datasource
                //does NOT have that field and so the renderer is invalid).
                //
                //#2: By default, Layers are added with a permanent cache. The cache is NOT automatically
                //invalidated so data (eg in the Attribute table, on the screen for draws) does NOT get
                //Refreshed so you have to invalidate the cache manually...

                //So, Bug #1 - we arbitrarily switch the Renderer to a simple renderer as a work around for that...
                featureLayer.SetRenderer(featureLayer.CreateRenderer(new SimpleRendererDefinition()));

                //Bug #2, we manually invalidate the cache
                featureLayer.ClearDisplayCache();
            });
        }
开发者ID:ChaitG,项目名称:arcgis-pro-sdk-community-samples,代码行数:67,代码来源:ChangeLayerDataSource.cs


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