将下列代码放入MouseDown事件中,可以实现点选或者矩形选择要素。
1
IMap pMap;
2
IPoint pPoint;
3
pMap = axMapControl1.Map;
4
pPoint = axMapControl1.ToMapPoint(e.x, e.y);
5
6
IIdentify pIdentify;
7
pIdentify = (IIdentify)pMap.get_Layer(0);
8
9
IArray pIDArray;
10
IFeatureIdentifyObj pFeatIdObj;
11
IIdentifyObj pIdObj;
12
//点选
13
IEnvelope pEnv=new EnvelopeClass();
14
pEnv =axMapControl1.ActiveView.Extent;
15
pEnv.Height= 100;
16
pEnv.Width = 100;
17
pEnv.CenterAt(pPoint);
18
pIDArray = pIdentify.Identify(pEnv);
19
//矩形选择
20
//IEnvelope testIRectangleElement;
21
//testIRectangleElement = axMapControl1.TrackRectangle();
22
//pIDArray = pIdentify.Identify(testIRectangleElement);
23
//i = pIDArray.Count;
24
if (pIDArray != null)
25
(部分代码来自ESRI中国社区)2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25