|
阅读:1604回复:2
求教:直线怎么也画不出来_ArcEngine_C#
<P>刚学AO,我想在地图上通过两个点画一条线,这些点坐标都是从我的鼠标坐标得来。但是在代码 pEle.Geometry = line as IGeometry; 那个地方总是抱错:alue does not fall within the expected range, 请大侠指导,谢谢。具体代码块如下</P>
<P><BR> IPoint pt2 = new PointClass();<BR> pt2.X = e.mapX;<BR> pt2.Y = e.mapY;<BR> ILineElement pline = new LineElementClass();<BR> ILineSymbol sym = new SimpleLineSymbolClass();<BR> sym.Color.RGB = Color.Blue.ToArgb();<BR> sym.Width = 10;<BR> pline.Symbol = sym;</P> <P> ILine2 line = new LineClass();<BR> line.PutCoords(pt, pt2); //pt也是IPoint类型</P> <P> IElement pEle = pline as IElement;<BR> pEle.Geometry = line as IGeometry;</P> <P> pmap.AddElement((IElement)pline, 0); //出错<BR> m_mapControl.ActiveView.PartialRefresh(...);</P> |
|
|
1楼#
发布于:2007-10-31 12:38
alue does not fall within the expected range<br>你的坐标超出建库是的bounds了吧?!<br><br>
|
|
|
2楼#
发布于:2007-10-31 16:07
<P>我觉得应该是:</P>
<P>IElement pEle = new LineElementClass();</P> <P>pEle.Geometry = line as IGeometry;</P> <P>pmap.AddElement(pEle, 0); </P> |
|
|