ArcGIS API for Silverlight 添加图标(自定义图标)

2016-02-19 08:25:02来源:CSDN作者:evanyanglibo人点击

private void AddPlaceMarker(double LocationX, double LocationY)

        {

            //将要添加图标的图层   GraphicsLayer

            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;


            //new 图标

            ESRI.ArcGIS.Client.Graphic aGraphic = new ESRI.ArcGIS.Client.Graphic();


            //参考缩放级别

            ESRI.ArcGIS.Client.Geometry.SpatialReference aSpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100);


            //设置图标位置

            ESRI.ArcGIS.Client.Geometry.MapPoint aMapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint();

            aMapPoint.SpatialReference = aSpatialReference;

            aMapPoint.X = LocationX;

            aMapPoint.Y = LocationY;


            //设置图标样式

            ESRI.ArcGIS.Client.Symbols.PictureMarkerSymbol aPictureMarkerySymbol = new ESRI.ArcGIS.Client.Symbols.PictureMarkerSymbol();

            ImageSource imageSource = new BitmapImage(new Uri("camara.jpg", UriKind.RelativeOrAbsolute));

            aPictureMarkerySymbol.Source = imageSource;

            aPictureMarkerySymbol.Width = 16;

            aPictureMarkerySymbol.Height = 16;


            //绑定图标位置和样式

            aGraphic.Geometry = (ESRI.ArcGIS.Client.Geometry.Geometry)aMapPoint;

            aGraphic.Symbol = aPictureMarkerySymbol;


            //将图标显示到图层

            graphicsLayer.Graphics.Add(aGraphic);

        }

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台