1.如果是更新数据后重绘,需要先删除原来的element
pLElement是上次为这个点创建的element。
if (pLElement != null)
{
graphicsContainer.DeleteElement(pLElement);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pLElement, null);
}
2.创建点
markclass是自定义类,包括经度longitude、纬度latitude、图标路径pattern等成员。
IPoint pPoint = ConstructPoint(markclass.longitude, markclass.latitude);//点位
IPictureMarkerSymbol picMarker = new PictureMarkerSymbol();
picMarker.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, markclass.pattern);//图片
IRgbColor color = new RgbColor();
color.Red = 255;
color.Green = 255;
color.Blue = 255;
picMarker.BitmapTransparencyColor = (IColor)color;//设置透明色
picMarker.Size = 40;
IMarkerElement pLE;
pLElement = new MarkerElement() as IElement;
pLE = pLElement as IMarkerElement;
pLE.Symbol = (IMarkerSymbol)picMarker;//确定元素样式,图像
pLElement.Geometry = pPoint;//确定元素坐标
//显示到地图
graphicsContainer.AddElement(pLElement, 0);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pLElement, null);