ArcGIS API for Silverlight 通过经纬度添加图标

2015-08-27 21:35:12来源:CSDN作者:evanyanglibo人点击

private void AddPlaceMarkerByLongitudeAndLatitude(double Longitude, double Latitude)

        {

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

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


            //new 图标

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


            //设置图标样式

            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;


            //绑定图标位置和样式

            ESRI.ArcGIS.Client.Projection.WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator();

            aGraphic.Geometry = mercator.FromGeographic(new MapPoint(Longitude, Latitude));

            aGraphic.Symbol = aPictureMarkerySymbol;


            //将图标显示到图层

            graphicsLayer.Graphics.Add(aGraphic);

        }

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台