• 测量面积


    在页面上添加测量工具的图标:

    <esri:Tool ClientAction="Polygon" JavaScriptFile="" Name="AreaPolygon" DefaultImage="Images/MapTool/MeasurePoly1.gif"
    HoverImage="Images/MapTool/MeasurePoly2.gif" SelectedImage="Images/MapTool/MeasurePoly2.gif"
    Text="面积" ToolTip="面积" ServerActionAssembly="App_Code" ServerActionClass="IdentifyArea" />

    在app_code里面添加IdentifyArea方法,代码如下:

    /// <summary>
    ///IdentifyArea 的摘要说明 计算面积
    /// </summary>
    public class IdentifyArea : IMapServerToolAction
    {
    public IdentifyArea()
    {
    //
    //TODO: 在此处添加构造函数逻辑
    //
    }

    void IMapServerToolAction.ServerAction(ToolEventArgs args)
    {
    Map MapControl = args.Control as Map;//得到地图资源
    MapPolygonEventArgs MyPolygonArg = (MapPolygonEventArgs)args;//得到地图中的线对象
    System.Drawing.Point[] screen_points = MyPolygonArg.Vectors;//得到线的点集合
    Double X1 = 0, Y1 = 0, X2 = 0, Y2 = 0;
    Double XD = 0.0;
    Double YD = 0.0;
    Double AllArea = 0.0;
    Double TempArea = 0.0;

    //起始点
    ESRI.ArcGIS.ADF.Web.Geometry.Point Point1 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points[0], MapControl.Extent, (Int32)MapControl.Width.Value, (Int32)MapControl.Height.Value);

    X1 = Point1.X;
    Y1 = Point1.Y;

    for (int i = 1; i < screen_points.Length; i++)
    {
    //得到与起始点的距离
    ESRI.ArcGIS.ADF.Web.Geometry.Point Point2 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points[i], MapControl.Extent, (Int32)MapControl.Width.Value, (Int32)MapControl.Height.Value);

    X2 = Point2.X;
    Y2 = Point2.Y;

    XD = X2 - X1;
    YD = Y2 - Y1;
    TempArea = X1 * YD - Y1 * XD;
    AllArea += TempArea;

    Point1 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points[0], MapControl.Extent, (Int32)MapControl.Width.Value, (Int32)MapControl.Height.Value);

    X1 = Point1.X;
    Y1 = Point1.Y;


    }
    AllArea = Math.Abs(AllArea) / 2;
    AllArea = Math.Round(AllArea, 2);


    string jstext = "alert('总计:" + AllArea.ToString() + "平方米');";
    CallbackResult cr_lei = new CallbackResult(null, null, "javascript", jstext);

    MapControl.CallbackResults.Add(cr_lei);

    }

  • 相关阅读:
    ubuntu降低你使用的内核到指定版本
    无线传感网——zigbee基础实验-点对点通信
    使用ARP对局域网进行欺骗攻击
    12.垃圾收集底层算法--三色标记详解
    11. 亿级流量电商系统JVM模型参数二次优化
    10. 系统分析垃圾收集器
    9.亿级流量电商系统JVM模型参数预估方案
    8.JVM内存分配机制超详细解析
    UE4的PawnSensingComponent人形感应组件
    python2.7源码编译安装pyqt5
  • 原文地址:https://www.cnblogs.com/lff255356/p/2741003.html
Copyright © 2020-2023  润新知