Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用特定颜色绘制到ESRI.ArcGIS.Client.FeatureLayer上_C#_Wpf_Arcgis - Fatal编程技术网

C# 使用特定颜色绘制到ESRI.ArcGIS.Client.FeatureLayer上

C# 使用特定颜色绘制到ESRI.ArcGIS.Client.FeatureLayer上,c#,wpf,arcgis,C#,Wpf,Arcgis,我试图建立一个功能,让用户绘制到具有特定颜色的特定功能层。通过更改FeatureLayer.Renderer,层上的所有注释都将更改为指定的颜色,甚至是上一个会话中的注释。我希望能够有他们的特定颜色的旧注释那里和新的被绘制他们的特定颜色(可能不同) 这里是定义地图和要素图层的XAML <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDicti

我试图建立一个功能,让用户绘制到具有特定颜色的特定功能层。通过更改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>

渲染器应用于层中的所有特征(图形),因此如果要使用渲染器,可以使用唯一值渲染器并为不同的属性值设置不同的样式,尽管这意味着您知道在定义颜色时要使用哪些值。类似地,如果希望基于一系列值控制颜色,则可以使用类中断渲染器

但在您的情况下,您可能只想为功能设置特定符号,因为符号将覆盖渲染器。您只需将符号应用于图形即可使用它。e、 g

var markerSym = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol
{
    Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Diamond,
    Color = Colors.Green,
    Size = 18
};

var pointGraphic = new Esri.ArcGISRuntime.Layers.Graphic(point, markerSym);

graphicsLayer.Graphics.Add(pointGraphic);
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;
}
var markerSym = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol
{
    Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Diamond,
    Color = Colors.Green,
    Size = 18
};

var pointGraphic = new Esri.ArcGISRuntime.Layers.Graphic(point, markerSym);

graphicsLayer.Graphics.Add(pointGraphic);