1.ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality类代表了GraphicsLayer类型的MapFunctionality,提供了在地图上画图形的功能,并把图形存储在内存中。
2.ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer可以理解为ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality中的图层,其实就是一个DataTable。对应于ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality.GraphicsDataSet.Tables的一个DataTable。添加图层可以使用ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality.GraphicsDataSet.Tables.Add方法。
3.ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement可以理解为在ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer中的一个图形元素。可以使用ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer.Add方法添加一个ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement。
画点:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using System.Data;
using ESRI.ArcGIS.ADF.Web.Display.Symbol;
/// <summary>
///MapPoint 的摘要说明
/// </summary>
public class MapPoint : IMapServerToolAction
{
#region IMapServerToolAction 成员
public void ServerAction(ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolEventArgs args)
{
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map adfMap = args.Control as ESRI.ArcGIS.ADF.Web.UI.WebControls.Map;
if (args is ESRI.ArcGIS.ADF.Web.UI.WebControls.PointEventArgs)
{
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality mf = null;
PointEventArgs pointEventArgs = (PointEventArgs)args;
System.Drawing.Point point = new System.Drawing.Point(pointEventArgs.ScreenPoint.X, pointEventArgs.ScreenPoint.Y);
ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(
point, adfMap.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality m in adfMap.GetFunctionalities())
{
if (m is ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)
{
mf = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)m;
//mf中的一个ElementGraphicsLayer,该图层用来画点
ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer elementGraphicsLayer = null;
foreach (DataTable dt in mf.GraphicsDataSet.Tables)
{
if (dt.TableName == "点元素")
{
elementGraphicsLayer = mf.GraphicsDataSet.Tables["点元素"] as ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer;
break;
}
}
if (elementGraphicsLayer == null)
{
elementGraphicsLayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer("点元素");
//生成一个新的图层
mf.GraphicsDataSet.Tables.Add(elementGraphicsLayer);
}
SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(System.Drawing.Color.Red, 2, MarkerSymbolType.Circle);
ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement ge = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(adfPoint, symbol);
elementGraphicsLayer.Add(ge);
adfMap.RefreshResource(mf.Resource.Name);
}
}
}
}
#endregion
}