Hi, I want to add a graphics layer in Map. But this layer is lack of Spatial Reference. I cannot specify the spatial reference, because it's property is read only(just get is implemented in the API).Here is xaml (It is generated when I create an ESRI SL Application in Visual Studio)
<esri:Map x:Name="Map" Background="White">
....
....
<esri:Map.Layers>
<esri:ArcGISTiledMapServiceLayer ID="BaseLayer"
Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
</esri:Map.Layers>
</esri:Map>
I want to create Graphics Layer with the following code behind C# code
public GraphicsLayer CreatePointGraphicLayer(string ID,
SpatialReference spatial_reference,
List<double> x_list,
List<double> y_list,
List<string> fields,
List<string[]> other_fields_values)
{
GraphicsLayer graphics_layer = new GraphicsLayer();
graphics_layer.ID = ID;
SimpleMarkerSymbol simple_marker_symbol = new SimpleMarkerSymbol();
simple_marker_symbol.Color = new SolidColorBrush(Colors.Red);
for (int i = 0; i < x_list.Count; i++)
{
Graphic graphic = new Graphic()
{
Symbol = simple_marker_symbol,
Geometry = new MapPoint(x_list, y_list, spatial_reference)
};
for (int j = 0; j < fields.Count; j++)
{
graphic.Attributes[fields] = other_fields_values;
}
graphics_layer.Graphics.Add(graphic);
}
return graphics_layer;
}
The code above create the graphics layer and when I put it into Map with the following lines of code, I can see the created graphics but lack of spatial reference.
GraphicsLayer g_layer = CreatePointGraphicLayer(....) //I omit this part
Map.Layers.Add(g_layer);
How can I use spatial reference in graphics layer.Thanks in advance.Kerem.