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);
}
本文介绍了一种在地图上特定坐标位置添加图标的方法。通过创建并配置`GraphicsLayer`图层来实现图标显示,并设置了图标的样式及位置。该方法使用了ArcGIS API,包括设置空间参考、图标样式等步骤。
952

被折叠的 条评论
为什么被折叠?



