本文整理汇总了C#中FeatureLayer.CreateRenderer方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayer.CreateRenderer方法的具体用法?C# FeatureLayer.CreateRenderer怎么用?C# FeatureLayer.CreateRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FeatureLayer
的用法示例。
在下文中一共展示了FeatureLayer.CreateRenderer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateniqueValueRendererForUSHighwaysUsingDefinition
private CIMRenderer CreateniqueValueRendererForUSHighwaysUsingDefinition(FeatureLayer featureLayer) {
//All of these methods have to be called on the MCT
if (Module1.OnUIThread)
throw new CalledOnWrongThreadException();
// color ramp
CIMICCColorSpace colorSpace = new CIMICCColorSpace() {
URL = "Default RGB"
};
CIMContinuousColorRamp continuousColorRamp = new CIMLinearContinuousColorRamp();
continuousColorRamp.FromColor = CIMColor.CreateRGBColor(0, 0, 255); // yellow
continuousColorRamp.ToColor = CIMColor.CreateRGBColor(255, 0, 0); // red
continuousColorRamp.ColorSpace = colorSpace;
CIMRandomHSVColorRamp randomHSVColorRamp = new CIMRandomHSVColorRamp() {
ColorSpace = colorSpace,
MinAlpha = 100,
MaxAlpha = 100,
MinH = 0,
MaxH = 360,
MinS = 15,
MaxS = 30,
MinV = 99,
MaxV = 100,
Seed = 0
};
UniqueValueRendererDefinition uvRendererDef = new UniqueValueRendererDefinition() {
ColorRamp = continuousColorRamp, //randomHSVColorRamp,
UseDefaultSymbol = true,
ValueFields = new string[] {"ROUTE_NUM"}
};
//Configure the Renderer using the featureLayer and the contents of the STATENAM
//field
return featureLayer.CreateRenderer(uvRendererDef);
}
示例2: 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();
});
}