【发布时间】:2015-07-06 07:06:53
【问题描述】:
我正在尝试构建一个功能,让用户可以使用特定颜色绘制到特定功能图层上。通过更改 FeatureLayer.Renderer,图层上的所有注释都会更改为指定的颜色,即使是之前会话中的注释。我希望能够在那里使用特定颜色的旧注释,并使用特定颜色(可能不同)绘制新注释。
这是定义地图和要素图层的 XAML
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="GraphicsDictionary.xaml" x:Name="LineSymbolResourceDictionary"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Name="MapGrid">
<esri:Map x:Name="MyMap">
<esri:ArcGISTiledMapServiceLayer
ID="StreetMapLayer"
x:Name="BaseMap"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
>
</esri:ArcGISTiledMapServiceLayer>
<esri:FeatureLayer
ID="MyFeatureLayer"
x:Name="MyFeatureLayer"
Url="http://123.123.123.12:6080/arcgis/rest/services/Prj/FeatureServer/0"
Renderer="{StaticResource BlueSimpleRenderer}"
EndSaveEdits="drawLayer_EndSaveEdits"
>
</esri:FeatureLayer>
</esri:Map>
</Grid>
资源字典:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client"
xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
x:Class="ClassName.GraphicsDictionary"
>
<esri:SimpleRenderer x:Key="BlueSimpleRenderer">
<esri:SimpleRenderer.Symbol>
<esriSymbols:SimpleLineSymbol x:Name="BlueLineSymbol" Color="#00007F" Width="5"/>
</esri:SimpleRenderer.Symbol>
</esri:SimpleRenderer>
绘图的 C# 代码:
public void StartDrawing(FeatureLayer inputLayer, string inputColorInHex)
{
MyMap.Cursor = System.Windows.Input.Cursors.Pen;
//Below's the color that might be different from the original renderer
SimpleRenderer newRend= new SimpleRenderer
{
Symbol = new SimpleLineSymbol((Color)ColorConverter.ConvertFromString(inputColorInHex), 12)
};
inputLayer.Renderer = newRend as IRenderer;
MyDrawObject.DrawMode = ESRI.ArcGIS.Client.DrawMode.Freehand;
MyDrawObject.IsEnabled = true;
}
【问题讨论】: