ArcGIS.Server.9.2.DotNet在ElementGraphicsLayer画点、线、折线、面、圆、矩形的代码

本文详细阐述了如何通过交互操作在地图控件中添加不同类型的图形元素,包括点、线、多边形、圆和矩形,并介绍了如何在ArcGIS环境下使用相应的代码实现。重点展示了图形元素的创建、样式设置以及数据表格的动态更新。
public class AddTool:IMapServerToolAction 
    {
        public void ServerAction(ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolEventArgs args)
        {
            //获取map控件
            ESRI.ArcGIS.ADF.Web.UI.WebControls.Map adfMap = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control;
            ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality adfGraphicsMapFunctionality = null;


            if (args is PointEventArgs)
            {
                //转成点
                PointEventArgs pointEventArgs = (PointEventArgs)args;
                //屏幕点
                System.Drawing.Point screenPoint = pointEventArgs.ScreenPoint;
                //屏幕坐标转成地理坐标
                ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screenPoint.X, screenPoint.Y, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                
                //MapFunctionality
                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
                {
                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
                    if (mapFunctionality.Resource.Name == "GraphicsResource")
                    {
                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
                        break;
                    }
                }
                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
                {
                    if (dataTable.TableName == "Element Graphics")
                    {
                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
                        break;
                    }
                }
                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
                if (elementGraphicsLayer == null)
                {
                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
                    elementGraphicsLayer.TableName = "Element Graphics";
                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
                }


                //定义标点样式
                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol();
                //simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
                simpleMarkerSymbol.Color = System.Drawing.Color.Green;
                simpleMarkerSymbol.Width = 10;


                //定义标点选中样式
                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol();
                simpleSelectedMarkerSymbol.Color = System.Drawing.Color.Yellow;
                simpleSelectedMarkerSymbol.Width = 12;
                simpleSelectedMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;


                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(adfPoint, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
                //把标点添加到elementGraphicsLayer
                elementGraphicsLayer.Add(graphicElement);
                
            }
            else if(args is LineEventArgs)
            {
                //转成点
                LineEventArgs lineEventArgs = (LineEventArgs)args;
                //屏幕点
                //屏幕坐标转成地理坐标
                ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint1 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(lineEventArgs.BeginPoint.X, lineEventArgs.BeginPoint.Y, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                //屏幕坐标转成地理坐标
                ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint2 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(lineEventArgs.EndPoint.X, lineEventArgs.EndPoint.Y, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                ESRI.ArcGIS.ADF.Web.Geometry.Path pa=new ESRI.ArcGIS.ADF.Web.Geometry.Path();
                pa.Points.Add(adfPoint1);
                pa.Points.Add(adfPoint2);
                ESRI.ArcGIS.ADF.Web.Geometry.Polyline Line = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline();
                Line.Paths.Add(pa);


                //MapFunctionality
                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
                {
                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
                    if (mapFunctionality.Resource.Name == "GraphicsResource")
                    {
                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
                        break;
                    }
                }
                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
                {
                    if (dataTable.TableName == "Element Graphics")
                    {
                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
                        break;
                    }
                }
                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
                if (elementGraphicsLayer == null)
                {
                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
                    elementGraphicsLayer.TableName = "Element Graphics";
                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
                }


                //定义标点样式
                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
                //simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
                simpleMarkerSymbol.Color = System.Drawing.Color.Red;
                simpleMarkerSymbol.Width = 3;
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.LineType.Dash;
                //定义标点选中样式
                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
                simpleSelectedMarkerSymbol.Color = System.Drawing.Color.Yellow;
                simpleSelectedMarkerSymbol.Width = 3;
                //simpleSelectedMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;


                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(Line, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
                //把标点添加到elementGraphicsLayer
                elementGraphicsLayer.Add(graphicElement);
                
            }
            else if (args is PolylineEventArgs)
            {
                PolylineEventArgs lineEventArgs = (PolylineEventArgs)args;
                ESRI.ArcGIS.ADF.Web.Geometry.Path pa = new ESRI.ArcGIS.ADF.Web.Geometry.Path();
                for (int i = 0; i <= lineEventArgs.Vectors.Length - 1; i++)
                {
                    ESRI.ArcGIS.ADF.Web.Geometry.Point point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(lineEventArgs.Vectors[i].X, lineEventArgs.Vectors[i].Y, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                    pa.Points.Add(point);
                }
                ESRI.ArcGIS.ADF.Web.Geometry.Polyline Line = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline();
                Line.Paths.Add(pa);


                //MapFunctionality
                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
                {
                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
                    if (mapFunctionality.Resource.Name == "GraphicsResource")
                    {
                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
                        break;
                    }
                }
                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
                {
                    if (dataTable.TableName == "Element Graphics")
                    {
                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
                        break;
                    }
                }
                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
                if (elementGraphicsLayer == null)
                {
                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
                    elementGraphicsLayer.TableName = "Element Graphics";
                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
                }


                //定义标点样式
                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
                //simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
                simpleMarkerSymbol.Color = System.Drawing.Color.Red;
                simpleMarkerSymbol.Width = 3;
                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.LineType.Dash;
                //定义标点选中样式
                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
                simpleSelectedMarkerSymbol.Color = System.Drawing.Color.Yellow;
                simpleSelectedMarkerSymbol.Width = 3;
                //simpleSelectedMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;


                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(Line, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
                //把标点添加到elementGraphicsLayer
                elementGraphicsLayer.Add(graphicElement);
            }
            else if (args is PolygonEventArgs)
            {
                PolygonEventArgs polygonEventArgs = (PolygonEventArgs)args;
                ESRI.ArcGIS.ADF.Web.Geometry.Ring points = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
                for (int i = 0; i <= polygonEventArgs.Vectors.Length - 1; i++)
                {
                    ESRI.ArcGIS.ADF.Web.Geometry.Point point = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(polygonEventArgs.Vectors[i].X, polygonEventArgs.Vectors[i].Y, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                    points.Points.Add(point);
                }
                ESRI.ArcGIS.ADF.Web.Geometry.Polygon polygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
                polygon.Rings.Add(points);


                //MapFunctionality
                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
                {
                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
                    if (mapFunctionality.Resource.Name == "GraphicsResource")
                    {
                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
                        break;
                    }
                }
                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
                {
                    if (dataTable.TableName == "Element Graphics")
                    {
                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
                        break;
                    }
                }
                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
                if (elementGraphicsLayer == null)
                {
                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
                    elementGraphicsLayer.TableName = "Element Graphics";
                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
                }


                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
                simpleMarkerSymbol.Color = System.Drawing.Color.Yellow;
                simpleMarkerSymbol.FillType= ESRI.ArcGIS.ADF.Web.Display.Symbol.PolygonFillType.DiagCross;


                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(polygon, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
                //把标点添加到elementGraphicsLayer
                elementGraphicsLayer.Add(graphicElement);
       
            }
            else if (args is CircleEventArgs)
            {
                CircleEventArgs circleEventArgs = (CircleEventArgs)args;
                
                ESRI.ArcGIS.ADF.Web.Geometry.PointCollection pc = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
                double degree;
                double rad  = circleEventArgs.Radius;
                for (int i = 0; i < 359; i++)
                { 
                    degree = i * (Math.PI / 180);
                    double x = circleEventArgs.CenterPoint.X + Math.Cos(degree) * rad;
                    double y = circleEventArgs.CenterPoint.Y + Math.Sin(degree) * rad;
                    ESRI.ArcGIS.ADF.Web.Geometry.Point nPoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint((int)Math.Round(x),(int)Math.Round(y), adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                    pc.Add(nPoint);
                }
                ESRI.ArcGIS.ADF.Web.Geometry.Ring ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
                ring.Points = pc;
                ESRI.ArcGIS.ADF.Web.Geometry.RingCollection rings = new ESRI.ArcGIS.ADF.Web.Geometry.RingCollection();
                rings.Add(ring);
                ESRI.ArcGIS.ADF.Web.Geometry.Polygon polygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
                polygon.Rings = rings;


                //MapFunctionality
                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
                {
                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
                    if (mapFunctionality.Resource.Name == "GraphicsResource")
                    {
                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
                        break;
                    }
                }
                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
                {
                    if (dataTable.TableName == "Element Graphics")
                    {
                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
                        break;
                    }
                }
                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
                if (elementGraphicsLayer == null)
                {
                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
                    elementGraphicsLayer.TableName = "Element Graphics";
                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
                }


                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
                simpleMarkerSymbol.Color = System.Drawing.Color.Yellow;
                simpleMarkerSymbol.FillType = ESRI.ArcGIS.ADF.Web.Display.Symbol.PolygonFillType.DiagCross;


                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(polygon, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
                //把标点添加到elementGraphicsLayer
                elementGraphicsLayer.Add(graphicElement);


            }
            else if(args is RectangleEventArgs)
            {
                RectangleEventArgs rectargs = (RectangleEventArgs)args;
                //矩形
                System.Drawing.Rectangle myrect = rectargs.ScreenExtent;
                //矩形左下定点坐标转换成地理坐标
                ESRI.ArcGIS.ADF.Web.Geometry.Point minpnt = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Left, myrect.Bottom, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                //矩形右上定点坐标转换成地理坐标
                ESRI.ArcGIS.ADF.Web.Geometry.Point maxpnt = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(myrect.Right, myrect.Top, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
                //
                ESRI.ArcGIS.ADF.Web.Geometry.Envelope mappoly = new ESRI.ArcGIS.ADF.Web.Geometry.Envelope(minpnt, maxpnt);


                //MapFunctionality
                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
                {
                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
                    if (mapFunctionality.Resource.Name == "GraphicsResource")
                    {
                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
                        break;
                    }
                }
                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
                {
                    if (dataTable.TableName == "Element Graphics")
                    {
                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
                        break;
                    }
                }
                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
                if (elementGraphicsLayer == null)
                {
                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
                    elementGraphicsLayer.TableName = "Element Graphics";
                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
                }


                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
                simpleMarkerSymbol.Color = System.Drawing.Color.Yellow;
                simpleMarkerSymbol.FillType = ESRI.ArcGIS.ADF.Web.Display.Symbol.PolygonFillType.DiagCross;


                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(mappoly, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
                //把标点添加到elementGraphicsLayer
                elementGraphicsLayer.Add(graphicElement);


            }


            //刷新显示
            if (adfMap.ImageBlendingMode == ImageBlendingMode.WebTier)
            {
                //整个地图控件刷新
                adfMap.Refresh();
            }
            else
            {
                //只刷新部分Resource
                adfMap.RefreshResource(adfGraphicsMapFunctionality.Resource.Name);
            }
        }


    }
转自:http://www.cnblogs.com/hll2008/archive/2008/10/13/1310381.html
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值