zoukankan      html  css  js  c++  java
  • 测量距离

    在页面上添加一个工具:

    <esri:Tool ClientAction="Polyline" JavaScriptFile="" Name="RangeLine" DefaultImage="Images/MapTool/MeasureLine1.gif"
    HoverImage="Images/MapTool/MeasureLine2.gif" SelectedImage="Images/MapTool/MeasureLine2.gif"
    Text="测距" ToolTip="测距" ServerActionAssembly="App_Code" ServerActionClass="IdentifyRange" />

    在app_code里面添加IdentifyRange类,代码如下:

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

    #region IMapServerToolAction 成员

    void IMapServerToolAction.ServerAction(ToolEventArgs args)
    {
    Map MapControl = args.Control as Map;//得到地图资源
    MapPolylineEventArgs MyPolylineArg = (MapPolylineEventArgs)args;//得到地图中的线对象
    System.Drawing.Point[] screen_points = MyPolylineArg.Vectors;//得到线的点集合
    Double X1 = 0, Y1 = 0, X2 = 0, Y2 = 0;
    Double XD = 0.0;
    Double YD = 0.0;
    Double AllDis = 0.0;
    Double TempDis = 0.0;
    for (int i = 0; i < screen_points.Length; i++)
    {
    if (i == 0)
    {
    //起始点
    ESRI.ArcGIS.ADF.Web.Geometry.Point mappnt = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points[i], MapControl.Extent, (Int32)MapControl.Width.Value, (Int32)MapControl.Height.Value);

    X1 = mappnt.X;
    Y1 = mappnt.Y;
    }
    else
    {
    //得到与起始点的距离
    ESRI.ArcGIS.ADF.Web.Geometry.Point mappnt2 = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_points[i], MapControl.Extent, (Int32)MapControl.Width.Value, (Int32)MapControl.Height.Value);

    X2 = mappnt2.X;
    Y2 = mappnt2.Y;

    XD = Math.Abs(X1 - X2);
    YD = Math.Abs(Y1 - Y2);
    // '计算2个坐标之间的距离
    TempDis = Math.Sqrt(Math.Pow(XD, 2) + Math.Pow(YD, 2));
    AllDis += TempDis;

    }
    }
    AllDis = Math.Round(AllDis, 2);

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

    MapControl.CallbackResults.Add(cr_lei);

    }

    #endregion
    }

  • 相关阅读:
    cs231n--详解卷积神经网络
    Spring 2017 Assignments2
    深度神经网络基础
    cs231n官方note笔记
    Spring 2017 Assignments1
    问题
    win7下解决vs2015新建项目,提示“未将对象引用设置到引用实例“的问题
    项目二:人脸识别
    ubutu强制关闭应用程序的方法
    将caj文件转化为pdf文件进行全文下载脚本(ubuntu下亲测有用)
  • 原文地址:https://www.cnblogs.com/lff255356/p/2741000.html
Copyright © 2011-2022 走看看