上一节学习了silverlight加载GeoServer发布的WMS地图,这一节学习一下加载GraphicsLayer
一、在MainPage.xaml中添加资源配置
<Grid.Resources>
<esri:SimpleMarkerSymbol x:Key="RedMarkerSymbol" Color="Red" Size="12" Style="Circle" />
<esri:SimpleMarkerSymbol x:Key="BlackMarkerSymbol" Color="Black" Size="14" Style="Diamond" />
<esri:PictureMarkerSymbol x:Key="GlobePictureSymbol" OffsetX="8" OffsetY="8"
Source="images/ttt.png" />
<esri:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="Green" Style="DashDot" Width="4" />
<esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="Green" BorderBrush="Blue"
BorderThickness="3" />
</Grid.Resources>
二、在cs文件中添加实现函数(以添加图片图标为例,添加其它请参考api官网)
private static ESRI.ArcGIS.Client.Projection.WebMercator mercator =
new ESRI.ArcGIS.Client.Projection.WebMercator();
private void AddPictureMarkerAndTextGraphics()
{
GraphicsLayer g = new ESRI.ArcGIS.Client.GraphicsLayer();
for (int i = 0; i < 2; i++)
Graphic graphic = new Graphic()
{
Geometry = mercator.FromGeographic(new MapPoint(107.2 + i, 38.1 + i)),
Symbol = LayoutRoot.Resources["GlobePictureSymbol"] as Symbol
};
g.Graphics.Add(graphic);
}
this.myMap.Layers.Add(g);
}
添加System.Runtime.Serialization引用
三、调用AddPictureMarkerAndTextGraphics()