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

  1public class AddTool:IMapServerToolAction  
  2    {
  3
  4
  5        public void ServerAction(ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolEventArgs args)
  6        {
  7            //获取map控件
  8            ESRI.ArcGIS.ADF.Web.UI.WebControls.Map adfMap = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control;
  9            ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality adfGraphicsMapFunctionality = null;
 10
 11            if (args is PointEventArgs)
 12            {
 13                //转成点
 14                PointEventArgs pointEventArgs = (PointEventArgs)args;
 15                //屏幕点
 16                System.Drawing.Point screenPoint = pointEventArgs.ScreenPoint;
 17                //屏幕坐标转成地理坐标
 18                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));
 19                
 20                //MapFunctionality
 21                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
 22                {
 23                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
 24                    if (mapFunctionality.Resource.Name == "GraphicsResource")
 25                    {
 26                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
 27                        break;
 28                    }
 29                }
 30                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
 31                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
 32                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
 33                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
 34                {
 35                    if (dataTable.TableName == "Element Graphics")
 36                    {
 37                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
 38                        break;
 39                    }
 40                }
 41                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
 42                if (elementGraphicsLayer == null)
 43                {
 44                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
 45                    elementGraphicsLayer.TableName = "Element Graphics";
 46                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
 47                }
 48
 49                //定义标点样式
 50                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol();
 51                //simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
 52                simpleMarkerSymbol.Color = System.Drawing.Color.Green;
 53                simpleMarkerSymbol.Width = 10;
 54
 55                //定义标点选中样式
 56                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleMarkerSymbol();
 57                simpleSelectedMarkerSymbol.Color = System.Drawing.Color.Yellow;
 58                simpleSelectedMarkerSymbol.Width = 12;
 59                simpleSelectedMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
 60
 61                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(adfPoint, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
 62                //把标点添加到elementGraphicsLayer
 63                elementGraphicsLayer.Add(graphicElement);
 64                
 65            }
 66            else if(args is LineEventArgs)
 67            {
 68                //转成点
 69                LineEventArgs lineEventArgs = (LineEventArgs)args;
 70                //屏幕点
 71                //屏幕坐标转成地理坐标
 72                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));
 73                //屏幕坐标转成地理坐标
 74                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));
 75                ESRI.ArcGIS.ADF.Web.Geometry.Path pa=new ESRI.ArcGIS.ADF.Web.Geometry.Path();
 76                pa.Points.Add(adfPoint1);
 77                pa.Points.Add(adfPoint2);
 78                ESRI.ArcGIS.ADF.Web.Geometry.Polyline Line = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline();
 79                Line.Paths.Add(pa);
 80
 81                //MapFunctionality
 82                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
 83                {
 84                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
 85                    if (mapFunctionality.Resource.Name == "GraphicsResource")
 86                    {
 87                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
 88                        break;
 89                    }
 90                }
 91                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
 92                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
 93                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
 94                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
 95                {
 96                    if (dataTable.TableName == "Element Graphics")
 97                    {
 98                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
 99                        break;
100                    }
101                }
102                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
103                if (elementGraphicsLayer == null)
104                {
105                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
106                    elementGraphicsLayer.TableName = "Element Graphics";
107                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
108                }
109
110                //定义标点样式
111                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
112                //simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
113                simpleMarkerSymbol.Color = System.Drawing.Color.Red;
114                simpleMarkerSymbol.Width = 3;
115                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.LineType.Dash;
116                //定义标点选中样式
117                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
118                simpleSelectedMarkerSymbol.Color = System.Drawing.Color.Yellow;
119                simpleSelectedMarkerSymbol.Width = 3;
120                //simpleSelectedMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
121
122                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(Line, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
123                //把标点添加到elementGraphicsLayer
124                elementGraphicsLayer.Add(graphicElement);
125                
126            }
127            else if (args is PolylineEventArgs)
128            {
129                PolylineEventArgs lineEventArgs = (PolylineEventArgs)args;
130                ESRI.ArcGIS.ADF.Web.Geometry.Path pa = new ESRI.ArcGIS.ADF.Web.Geometry.Path();
131                for (int i = 0; i <= lineEventArgs.Vectors.Length - 1; i++)
132                {
133                    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));
134                    pa.Points.Add(point);
135                }
136                ESRI.ArcGIS.ADF.Web.Geometry.Polyline Line = new ESRI.ArcGIS.ADF.Web.Geometry.Polyline();
137                Line.Paths.Add(pa);
138
139                //MapFunctionality
140                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
141                {
142                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
143                    if (mapFunctionality.Resource.Name == "GraphicsResource")
144                    {
145                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
146                        break;
147                    }
148                }
149                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
150                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
151                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
152                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
153                {
154                    if (dataTable.TableName == "Element Graphics")
155                    {
156                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
157                        break;
158                    }
159                }
160                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
161                if (elementGraphicsLayer == null)
162                {
163                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
164                    elementGraphicsLayer.TableName = "Element Graphics";
165                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
166                }
167
168                //定义标点样式
169                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
170                //simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
171                simpleMarkerSymbol.Color = System.Drawing.Color.Red;
172                simpleMarkerSymbol.Width = 3;
173                simpleMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.LineType.Dash;
174                //定义标点选中样式
175                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol();
176                simpleSelectedMarkerSymbol.Color = System.Drawing.Color.Yellow;
177                simpleSelectedMarkerSymbol.Width = 3;
178                //simpleSelectedMarkerSymbol.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.MarkerSymbolType.Star;
179
180                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(Line, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
181                //把标点添加到elementGraphicsLayer
182                elementGraphicsLayer.Add(graphicElement);
183            }
184            else if (args is PolygonEventArgs)
185            {
186                PolygonEventArgs polygonEventArgs = (PolygonEventArgs)args;
187                ESRI.ArcGIS.ADF.Web.Geometry.Ring points = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
188                for (int i = 0; i <= polygonEventArgs.Vectors.Length - 1; i++)
189                {
190                    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));
191                    points.Points.Add(point);
192                }
193                ESRI.ArcGIS.ADF.Web.Geometry.Polygon polygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
194                polygon.Rings.Add(points);
195
196                //MapFunctionality
197                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
198                {
199                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
200                    if (mapFunctionality.Resource.Name == "GraphicsResource")
201                    {
202                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
203                        break;
204                    }
205                }
206                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
207                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
208                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
209                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
210                {
211                    if (dataTable.TableName == "Element Graphics")
212                    {
213                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
214                        break;
215                    }
216                }
217                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
218                if (elementGraphicsLayer == null)
219                {
220                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
221                    elementGraphicsLayer.TableName = "Element Graphics";
222                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
223                }
224
225                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
226                simpleMarkerSymbol.Color = System.Drawing.Color.Yellow;
227                simpleMarkerSymbol.FillType= ESRI.ArcGIS.ADF.Web.Display.Symbol.PolygonFillType.DiagCross;
228
229                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
230                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(polygon, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
231                //把标点添加到elementGraphicsLayer
232                elementGraphicsLayer.Add(graphicElement);
233       
234            }
235            else if (args is CircleEventArgs)
236            {
237                CircleEventArgs circleEventArgs = (CircleEventArgs)args;
238                
239                ESRI.ArcGIS.ADF.Web.Geometry.PointCollection pc = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
240                double degree;
241                double rad  = circleEventArgs.Radius;
242                for (int i = 0; i < 359; i++)
243                
244                    degree = i * (Math.PI / 180);
245                    double x = circleEventArgs.CenterPoint.X + Math.Cos(degree) * rad;
246                    double y = circleEventArgs.CenterPoint.Y + Math.Sin(degree) * rad;
247                    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));
248                    pc.Add(nPoint);
249                }
250                ESRI.ArcGIS.ADF.Web.Geometry.Ring ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
251                ring.Points = pc;
252                ESRI.ArcGIS.ADF.Web.Geometry.RingCollection rings = new ESRI.ArcGIS.ADF.Web.Geometry.RingCollection();
253                rings.Add(ring);
254                ESRI.ArcGIS.ADF.Web.Geometry.Polygon polygon = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
255                polygon.Rings = rings;
256
257                //MapFunctionality
258                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
259                {
260                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
261                    if (mapFunctionality.Resource.Name == "GraphicsResource")
262                    {
263                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
264                        break;
265                    }
266                }
267                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
268                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
269                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
270                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
271                {
272                    if (dataTable.TableName == "Element Graphics")
273                    {
274                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
275                        break;
276                    }
277                }
278                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
279                if (elementGraphicsLayer == null)
280                {
281                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
282                    elementGraphicsLayer.TableName = "Element Graphics";
283                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
284                }
285
286                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
287                simpleMarkerSymbol.Color = System.Drawing.Color.Yellow;
288                simpleMarkerSymbol.FillType = ESRI.ArcGIS.ADF.Web.Display.Symbol.PolygonFillType.DiagCross;
289
290                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
291                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(polygon, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
292                //把标点添加到elementGraphicsLayer
293                elementGraphicsLayer.Add(graphicElement);
294
295            }
296            else if(args is RectangleEventArgs)
297            {
298                RectangleEventArgs rectargs = (RectangleEventArgs)args;
299                //矩形
300                System.Drawing.Rectangle myrect = rectargs.ScreenExtent;
301                //矩形左下定点坐标转换成地理坐标
302                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));
303                //矩形右上定点坐标转换成地理坐标
304                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));
305                //
306                ESRI.ArcGIS.ADF.Web.Geometry.Envelope mappoly = new ESRI.ArcGIS.ADF.Web.Geometry.Envelope(minpnt, maxpnt);
307
308                //MapFunctionality
309                foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality mapFunctionality in adfMap.GetFunctionalities())
310                {
311                    //当Resource为ADFGraphicsResource,ADFGraphicsResource为GraphicsLayer, 保存在内存中用显示临时图层
312                    if (mapFunctionality.Resource.Name == "GraphicsResource")
313                    {
314                        adfGraphicsMapFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)mapFunctionality;
315                        break;
316                    }
317                }
318                //从adfGraphicsMapFunctionality获取名为Element Graphics的DataTable
319                //ElementGraphicsLayers通常用来显示图形元素,例如显示Map中被选择的图形元素。图层并不用来存储属性,而可以存储不同的图形类型。
320                ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
321                foreach (System.Data.DataTable dataTable in adfGraphicsMapFunctionality.GraphicsDataSet.Tables)
322                {
323                    if (dataTable.TableName == "Element Graphics")
324                    {
325                        elementGraphicsLayer = (ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer)dataTable;
326                        break;
327                    }
328                }
329                //如果名为Element Graphics的DataTable为null,就新建Element Graphics DataTable添加到adfGraphicsMapFunctionality.GraphicsDataSet中,同时刷新Toc1显示
330                if (elementGraphicsLayer == null)
331                {
332                    elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
333                    elementGraphicsLayer.TableName = "Element Graphics";
334                    adfGraphicsMapFunctionality.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
335                }
336
337                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
338                simpleMarkerSymbol.Color = System.Drawing.Color.Yellow;
339                simpleMarkerSymbol.FillType = ESRI.ArcGIS.ADF.Web.Display.Symbol.PolygonFillType.DiagCross;
340
341                ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol simpleSelectedMarkerSymbol = new ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleFillSymbol();
342                ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement graphicElement = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(mappoly, simpleMarkerSymbol, simpleSelectedMarkerSymbol);
343                //把标点添加到elementGraphicsLayer
344                elementGraphicsLayer.Add(graphicElement);
345
346            }
347
348            //刷新显示
349            if (adfMap.ImageBlendingMode == ImageBlendingMode.WebTier)
350            {
351                //整个地图控件刷新
352                adfMap.Refresh();
353            }
354            else
355            {
356                //只刷新部分Resource
357                adfMap.RefreshResource(adfGraphicsMapFunctionality.Resource.Name);
358            }
359        }
360
361    }

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

  1. 【转】ArcGIS.Server.9.2.DotNet的ADF的Toolbar工作过程分析

    目的: 1.ArcGIS.Server.9.2.DotNet的ADF的Toolbar工作过程原理. 开始: Toolbar工作过程: 一.初始化过程(在页面生成的时候Toolbar控件会生成和它相关的 ...

  2. ArcGIS.Server.9.2.DotNet自带例子分析(三、一)

    目的: 1.arcgis server9.2 ADF的AddGraphics. 准备工作: 1.用ArcGis Server Manager或者ArcCatalog发布一个叫world的Map Ser ...

  3. ArcGIS.Server.9.2.DotNet自带例子分析(一、二)

    目的: 1.arcgis server9.2 ADF的无刷新机制. 准备: 1.(一.一)的工程,具体见前篇. 开始: 1. 先把上篇里漏下的ScaleBar(比例尺)和Magnifier(放大镜)功 ...

  4. arcgis server for .NET学习转载5

    http://www.cnblogs.com/hll2008/archive/2008/08/18/1269810.html 目的: 1.arcgis server9.2 ADF的Callback机制 ...

  5. ArcGIS.Server.9.3和ArcGIS API for Flex的GeometryService和buffer分析(十)

    目的: 1.ArcGIS API for Flex用GeometryService实现点.线.面的buffer分析.准备工作: 1.在ArcGIS.Server.9.3发布一个叫USA的Map Ser ...

  6. 总结基于ArcGIS Server 9.2 Dot Net ADF的WebGIS项目部署问题

    过去的几个月内对基于ArcGIS Server9.2的开发有所接触,这也是第一次真正自己动手作WebGIS的开发,期间遇到诸多问题.最突出的就是二次开发WebGIS的部署问题,以及字符集冲突的问题.问 ...

  7. 【转】ArcGIS Server安装

    转自 http://blog.csdn.net/ybgiser/article/details/3906269 一.ArcGIS Server产品包括两个部分: 1.GIS Server,它是一个提供 ...

  8. 【转】ArcGIS server如何将自己的小地图叠加到Google maps或者Virtual Earth上

    如果要将自己的数据与ArcGIS online的数据叠加使用,那么:1.应该选择后者为Primary Map Resource(有一种情况下,可以将自己的服务作为Primary Map Resourc ...

  9. ArcGIS server如何将自己的小地图叠加到Google maps或者Virtual Earth上

    http://hi.baidu.com/wiselyman/blog/item/d2dbd6f9dc83dc51242df2e2.html 我自己有个厂区的地图是cad的,转换为shape格式.然后将 ...

最新文章

  1. ​Leangoo在线SaaS模式的产品结构
  2. vue-router同路由$router.push不跳转一个简单解决方案
  3. CocosCreator游戏开发---菜鸟学习之路(三)如何在CocosCreator中使用Pomelo
  4. 亮眼的财报遇到疫情,阿里的生意会好做吗?
  5. Java社区目前的现状——交易
  6. 超励志!从中专生到教授,他32岁成为国家杰青!
  7. magento effects.js jquery.lazyload.js 冲突
  8. Redis常用数据类型和事物以及并发
  9. probability是什么意思_probability
  10. 一个很简单很简单的静态网页(附源代码)HTML+CSS
  11. 2022-2028年全球与中国汽车自动变速箱控制单元产业市场前瞻与投资战略规划分析
  12. Excel使用---excel2016___2维表转1维表(搬,侵删)
  13. 均值和方差的计算(已知两样本标准差,求总体标准差)
  14. 送给广大IT男同学的金句良言
  15. java executor 源码_Java线程池ThreadPoolExecutor深度探索及源码解析
  16. cmd 组合命令和管道命令的使用
  17. 以悠悠之生,立一技之长,而贞静自守
  18. 在某个文件目录中打开cmd的方法及快速获取文件路径的方法
  19. 基于谷歌油猴脚本观看视频
  20. Ubuntu20.04安装步骤详细指导

热门文章

  1. vueform表单文件上传_峰哥说技术系列-8.Spring Boot文件上传(Form表单和Ajax方式)
  2. php 获取对象中的元素个数组长度,获取php类中的数组长度
  3. 适合python爬虫使用的浏览器_python爬虫:使用Selenium模拟浏览器
  4. django开发个人博客
  5. linux系统命令行基础知识点
  6. atoi函数_吊打面试官 | 腾讯经典考点写代码实现atoi函数
  7. python vscode_VScode || 为VScode配置python环境
  8. 分析|CVE-2021-3156-sudo堆溢出高危漏洞
  9. python-css反爬之svg映射
  10. 剑指offer 变态跳台阶