ISegmentCollection pPath = new PathClass();
object o = Type.Missing;
IPoint startPoint = null;//起始點
foreach (DataRow dr2 in dt2.Rows)
{
if (startPoint == null)
{
startPoint = ConstructPoint(Convert.ToDouble(dr2["經度"]), Convert.ToDouble(dr2["緯度"]));
}
else
{
IPoint endPoint = ConstructPoint(Convert.ToDouble(dr2["經度"]), Convert.ToDouble(dr2["緯度"]));//終止點
ILine pLine = new LineClass();
pLine.FromPoint = startPoint;
pLine.ToPoint = endPoint;
//pLine.PutCoords(startPoint, endPoint);
pPath.AddSegment(pLine as ISegment, ref o, ref o);
startPoint = endPoint;
}
}
IGeometryCollection pPolyline = new PolylineClass();
pPolyline.AddGeometry(pPath as IGeometry, ref o, ref o);
ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
lineSymbol.Color = GetColor(colorValue);//顏色
lineSymbol.Style = esriSimpleLineStyle.esriSLSInsideFrame; //樣式
lineSymbol.Width = 2;
ILineElement pLineElement = new LineElementClass();
pLineElement.Symbol = lineSymbol;
IElement pElement = pLineElement as IElement;
tempGeometry = pElement.Geometry = pPolyline as IGeometry;
pGraphicsContainer.AddElement(pElement, 0);
兩點畫一條線
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.