2개 이상의 포인트 정보가 있을때 이 포인트를 이어 하나의 라인으로 그린다.
포인트를 포인트 콜렉션에 담아 그래픽 레이어에 라인을 생성한다.
public void Addpoint(){
//포인트 콜렉션 객체를 생성
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection ptcollection = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
//포인트 콜렉션에 포인트 정보를 추가
for (int j = 0; j < 조건; j++){
ESRI.ArcGIS.ADF.Web.Geometry.Point adfpoint = new ESRI.ArcGIS.ADF.Web.Geometry.Point("X좌표","Y좌쵸");
ptcollection .Add(adfpoint);
}
//그래픽 레이어에 라인을 그리기위한 함수 호출
AddGraphicsLine(Map1,ptcollection ,"line" ); //맵컨트롤, 포인트콜렉션,그래픽레이어명
Ma1.refreshResorce("line");
}
//포인트 콜렉션을 이용한 라인그리기
public void AddGraphicsLine(ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl,ESRI.ArcGIS.ADF.Web.Geometry.PointCollection adfpointcollection, string LayerName)
{
ESRI.ArcGIS.ADF.Web.Geometry.Path adfpath = new ESRI.ArcGIS.ADF.Web.Geometry.Path();
adfpath.Points = adfpointcollection;
ESRI.ArcGIS.ADF.Web.Geometry.PathCollection adfpaths = new ESRI.ArcGIS.ADF.Web.Geometry.PathCollection();
adfpaths.Add(adfpath);
ESRI.ArcGIS.ADF.Web.Geometry.Polyline Hurricanepath = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline();
Hurricanepath.Paths = adfpaths;
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality adfGraphicsMapFunctionality = null;
ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality = mapctrl.GetFunctionality(LayerName);
adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
{
if (dataTable.TableName == LayerName)
{
elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
break;
}
}
if (elementGraphicsLayer == null)
{
elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
elementGraphicsLayer.TableName = LayerName;
adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
}
//임의의 라인색 설정
Random ran = new Random();
int r = ran.Next(0, 256);
int g = ran.Next(0, 256);
int b = ran.Next(0, 256);
Color color = Color.FromArgb(r, g, b);
ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleline = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
//simpleline.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.LineType.Dash;
simpleline.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.LineType.Solid; //라인타입
simpleline.Width = 3; //라인굵기
simpleline.Color = color; //색을 지정하고 싶다면 System.Draw.Color.Red 처럼 지정하면 됨
ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(Hurricanepath, simpleline);
elementGraphicsLayer.Add(graphicElement);
}
'GIS' 카테고리의 다른 글
ArcGis Server (javascript) 축척 변경 (0) | 2010.01.13 |
---|---|
windows2008 서버 iis7.0 개발시 파일 다운로드 안될때 - shapefile(쉐입파일) MIME 설정 (0) | 2009.12.17 |
ArcGIS Server (ADF) Definition Query : 데피니션 쿼리 소스에서 구현하기 (0) | 2009.11.11 |
ArcGiS Server 9.3.X 쿼리필터(QueryFilter)시 maxrecords 500개 이상 가져오기 (Web ADF) (0) | 2009.11.09 |
(ArcObject-C#) SDE 공간정보 ShapeFile 컨버전, DBF(DBASE) 파일로 컨버전 (0) | 2009.10.01 |