C#Arcgis engine 获取axGlobeControl1的地理经纬度

 
        //'功能描述:三维地图上鼠标移动 获取坐标信息,并在状态栏显示
  

private void axGlobeControl1_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IGlobeControlEvents_OnMouseMoveEvent e)
        {
            try
            {

               //第一种办法
                //object AppOwner;
                //object AppObject;
                //IPoint Apoint;
                //this.axGlobeControl1.GlobeDisplay.Locate(this.axGlobeControl1.GlobeDisplay.ActiveViewer, e.x, e.y, false, true, out Apoint, out AppOwner, out AppObject);
                //this.lblzt.Text = "经度:" + Apoint.X.ToString("f6") + " 纬度:" + Apoint.Y.ToString("f6") + " 比例尺:";
  //第二种办法  此办法效率较快
                IGlobeViewUtil m_globeViewUtil = axGlobeControl1.GlobeCamera as IGlobeViewUtil;
                double dLon, dLat, dAlt;
                //convert the window coordinate into geographic coordinates
                m_globeViewUtil.WindowToGeographic(axGlobeControl1.GlobeDisplay,
                                                   axGlobeControl1.GlobeDisplay.ActiveViewer,
                                                   e.x,
                                                   e.y,
                                                   true,
                                                   out dLon,
                                                   out dLat,
                                                   out dAlt);
                this.lblzt.Text = "经度:" + dLon.ToString("f6") + " 纬度:" + dLat.ToString("f6") + " 比例尺:";
            }
            catch (Exception ex)
            {
                this.axGlobeControl1.GlobeDisplay.RefreshViewers();
                Class_Log4Net.WriteError("CheckGPS()检查GPS通信" + ex.Message + ex.Source);
            }

        }

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
您好!对于使用C#ArcGIS Engine获取图层字段信息,可以按照以下步骤进行操作: 1. 首先,确保您已经安装了ArcGIS Engine并在项目中添加了相应的引用。 2. 创建一个ArcGIS Engine的地图控件对象,用于加载和显示地图数据。 3. 加载您需要获取字段信息的地图数据。可以使用AxMapControl对象的LoadMxFile方法加载地图文档文件,或者使用Open方法加载地图文件。 4. 获取要操作的图层对象。可以使用AxMapControl对象的get_Layer方法获取指定名称或索引的图层对象。 5. 通过强制转换图层对象为IFeatureLayer接口,以便访问图层的要素类信息。 6. 通过IFeatureLayer接口的FeatureClass属性获取图层的要素类对象。 7. 通过IFeatureClass接口的Fields属性获取要素类的字段集合。 8. 遍历字段集合,获取每个字段的相关信息,比如字段名、类型等。 下面是一个示例代码片段,展示了如何实现上述步骤: ```csharp using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Geodatabase; // 加载地图数据 axMapControl1.LoadMxFile("path_to_mx_file"); // 获取目标图层 ILayer layer = axMapControl1.get_Layer(layerIndex); IFeatureLayer featureLayer = (IFeatureLayer)layer; // 获取要素类对象 IFeatureClass featureClass = featureLayer.FeatureClass; // 获取字段集合 IFields fields = featureClass.Fields; // 遍历字段集合 for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); string fieldName = field.Name; esriFieldType fieldType = field.Type; // 打印字段信息 Console.WriteLine("字段名称:{0},字段类型:{1}", fieldName, fieldType); } ``` 请注意,以上代码仅为示例,您需要根据您的具体需求进行相应的修改和适配。 希望对您有帮助!如有任何问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zkcharge

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值