C# Arcgis Engine 获得鼠标按下位置的要素
public IFeature GetFeatureOnMouseDown(IPoint point)
{
try
{
ILayer layer = Common.GetLayerByName(mMap, "地块");
if (layer == null)
{
MessageBox.Show("请加载地块图层!", "提示");
return null;
}
//IFeatureLayer fLayer = layer as IFeatureLayer;
//IFeatureSelection featureSelection = fLayer as IFeatureSelection;
//featureSelection.Clear();
//if (featureSelection == null)
//{
// return null;
//} IFeatureLayer featureLayer = layer as IFeatureLayer;
if (featureLayer == null)
return null;
IFeatureClass featureClass = featureLayer.FeatureClass;
if (featureClass == null)
return null; //IPoint point = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
IGeometry geometry = point as IGeometry; double length = ConvertPixelsToMapUnits(axMapControl1.ActiveView, );
ITopologicalOperator pTopo = geometry as ITopologicalOperator;
IGeometry buffer = pTopo.Buffer(length);
geometry = buffer.Envelope as IGeometry; ISpatialFilter spatialFilter = new SpatialFilterClass();
spatialFilter.Geometry = geometry;
switch (featureClass.ShapeType)
{
case esriGeometryType.esriGeometryPoint:
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
break;
case esriGeometryType.esriGeometryPolygon:
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
break;
case esriGeometryType.esriGeometryPolyline:
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
break;
}
spatialFilter.GeometryField = featureClass.ShapeFieldName;
IQueryFilter filter = spatialFilter as IQueryFilter; IFeatureCursor cursor = featureClass.Search(filter, false);
IFeature pfeature = cursor.NextFeature();
if (pfeature != null)
{
return pfeature;
//featureSelection.Add(pfeature);
//pfeature = cursor.NextFeature();
}
else
{
return null;
}
}
catch
{
return null;
}
}
大家可以修改一下我的代码,图层改成你需要的图层即可。也可以写成类。只是写成类的话,变量可能会多一点。
if (pfeature != null)
{
return pfeature;
//featureSelection.Add(pfeature);
//pfeature = cursor.NextFeature();
}
此处也可以将if改成while,如果选择的是多个要素的话。将我注释掉的代码打开即可选择多个要素。
C# Arcgis Engine 获得鼠标按下位置的要素的更多相关文章
- 最简单的ArcGIS Engine应用程序(下)
在中篇我们讲到使用OpenFileDialog控件可以添加shp文件.(最简单的ArcGIS Engine应用程序(中)) 添加lyr文件的操作也是大同小异的. using System; using ...
- ArcGIS Engine环境下创建自定义的ArcToolbox Geoprocessing工具
在上一篇日志中介绍了自己通过几何的方法合并断开的线要素的ArcGIS插件式的应用程序.但是后来考虑到插件式的程序的配置和使用比较繁琐,也没有比较好的错误处理机制,于是我就把之前的程序封装成一个类似于A ...
- ArcGIS Engine 下投影坐标和经纬度坐标的相互转换
ArcGIS Engine 下投影坐标和经纬度坐标的相互转换 投影转经纬度 ); pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)e ...
- VS2010下WPF开发ARCGIS ENGINE 10的带Ribbon控件项目
原文 http://blog.sina.com.cn/s/blog_47522f7f0100nq5t.html 题目好长,但是集目前最新的工具于一身..VS是最新的2010版,不过用的是.net3.5 ...
- JQuery使用mousedown和mouseup简单判断鼠标按下与释放位置是否相同
在JQuery中,我们可以利用mousedown.mouseup来跟踪页面的鼠标按下与释放事件. 如何获取鼠标的位置信息呢?事件event的pageX和pageY属性可以让我们获得鼠标在页面中的具体位 ...
- ArcGIS Engine开发之旅03--ArcGIS Engine中的控件
原文:ArcGIS Engine开发之旅03--ArcGIS Engine中的控件 制图控件,如MapControl.PageLayoutControl,其中MapControl控件主要用于地理数据的 ...
- 利用ArcGIS Engine、VS .NET和Windows控件开发GIS应用
Dixon 原文 用ArcGIS Engine.VS .NET和Windows控件开发GIS应用 此过程说明适合那些使用.NET建立和部署应用的开发者,它描述了使用ArcGIS控件建立和部署 ...
- 《ArcGIS Engine+C#实例开发教程》第五讲 鹰眼的实现
原文:<ArcGIS Engine+C#实例开发教程>第五讲 鹰眼的实现 摘要:所谓的鹰眼,就是一个缩略地图,上面有一个矩形框,矩形框区域就是当前显示的地图区域,拖动矩形框可以改变当前地图 ...
- ArcGIS Engine Style文件操作
对于一个GISer来说,地图,符号这些都应该有着比别人更深刻的理解和认识,作为平台软件都会提供一套自己的符号库,符号库里面根据类别和种类进行区分,因为点,线,面的自然存在和固有属性是不肯能让你用面状符 ...
随机推荐
- mac鼠标滚动方向自然问题
mac使用鼠标的时候滚轮方向和Windows是相反的.假设不勾选滚动方向自然,那么触摸板使用不爽. 解决的方法: 1.打开http://pilotmoon.com/scrollreverser/,下载 ...
- PermissionError: [Errno 13] in python
出现该错误,首先尝试以管理员身份运行 cmd.exe 程序,然后关闭所有的与 python 相关的进程. 1. open 打开一个文件夹(目录),而不是文件 这一错误一般发生在使用 open函数对文件 ...
- 6.deque
#include <iostream> #include <deque> #include <algorithm> using namespace std; //序 ...
- Codeforces434D 网络流
思路: 题意:有n<=50个点,每个点有xi有[li, ri]种取值,-100 <= li <= ri <= 100,并且给定m<=100条边,每条边为u,v,d表示xu ...
- android取高度
Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int top = r ...
- PHP万能的连接数据库
<?php class DB{ const HOST='127.0.0.1'; const USER='root'; const PASS='root'; const DATA='mooc'; ...
- hdu 3292 No more tricks, Mr Nanguo
No more tricks, Mr Nanguo Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Jav ...
- 实现echarts内外圈联动
//控制都是通过控制series中data的name,那么将内外圈需要同事控制的部分设置为一样的名字,就可以实现内外圈联动. //但是在name相同时,会使默认分配颜色时相同,使颜色不好看,这里就需要 ...
- tensorflow 问题库
1.module 'tensorflow.python.ops.nn' has no attribute 'rnn_cell' 将tf.nn.rnn_cell ->tf.contrib.rnn
- Linux Shell脚本编程-基础2
命令退出状态码 bash每个命令,执行状态都有返回值 0表示成功 非0表示失败(1-255) $?特殊变量可以打印出上一条命令的状态返回值 脚本的状态返回值是脚本执行的最后一条命令 自定义脚本状态返 ...