Engine中在地图上画线,并将其存入Mxd文档中,可以选中查询其属性值,有没有什么好的办法呢?

ILineElement pLineElement = new LineElementClass();
ISimpleLineSymbol pSimpleFillSymbol = new SimpleLineSymbolClass();
ESRI.ArcGIS.Geometry.IPolyline pPolyline = new ESRI.ArcGIS.Geometry.PolylineClass();
IRubberBand pRubberBand = new RubberLineClass();
pPolyline = (ESRI.ArcGIS.Geometry.IPolyline)pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null);
pSimpleFillSymbol.Color = bf.getRGB(78, 0, 150);
pSimpleFillSymbol.Width = 1;
pSimpleFillSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
IElement pElement = (IElement)pLineElement;
pElement.Geometry = pPolyline;
pLineElement.Symbol = pSimpleFillSymbol;
IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axMapControl1.Map;
pGraphicsContainer.AddElement((IElement)pLineElement, 0);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);我现在这种做法现实了在地图上画线,可是这个线是图片型的,没办法在Mxd文档上查询其属性值
已邀请:

朱新颖

赞同来自: why小飞 xiaosi9524

首先需要有一个要素类,然后创建一个IFeature,将生成的IPolyline赋予该Feature.Shape,并且赋予相应的字段属性,然后IFeature.Store();  就相当于在要素类中新增加了一条记录。就可以进行查询了。
Element是无法添加属性的。

why小飞

赞同来自:

可是线应该有起始点和终结点啊,这些属性怎么配置

xiaosi9524 - GISER

赞同来自:

你的代码创建的是Element,这个可以在地图上看到,但没有保存,所有你要创建线图层的时候自定义直线起点(StartPoint)、终点(EndPoint)字段,按照一楼的方法创建并保存要素就可以了

要回复问题请先登录注册