地图平移,可以说是最重要的功能之一,许多地图的默认工具就是平移。AE实现平移,比较简单,代码如下
1: /// <summary>
2: /// 地图漫游工具
3: /// </summary>
4: public class Pan : GISTools.Base.ToolBase
5: {
6:
7: private bool m_PanOperation;
8:
9: public Pan()
10: : base("Pan")
11: { }
12:
13: public Pan(AxMapControl mapCtl)
14: : base(mapCtl, "Pan")
15: {
16: if (m_cursor == null) m_cursor = getCursor(esriSystemMouseCursor.esriSystemMouseCursorPan);
17: }
18:
19: public Pan(AxPageLayoutControl plCtl)
20: : base(plCtl, "Pan")
21: {
22: if (m_cursor == null) m_cursor = getCursor(esriSystemMouseCursor.esriSystemMouseCursorPan);
23: }
24:
25: public override void OnMouseDown(int Button, int Shift, int X, int Y)
26: {
27: if (Button != 1) return;
28: IPoint point =m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
29: m_pActiveView.ScreenDisplay.PanStart(point);
30: m_PanOperation = true;
31: }
32:
33: public override void OnMouseMove(int Button, int Shift, int X, int Y)
34: {
35: if (Button != 1) return;
36:
37: if (!m_PanOperation) return;
38:
39: IPoint point = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
40: m_pActiveView.ScreenDisplay.PanMoveTo(point);
41: }
42:
43: public override void OnMouseUp(int Button, int Shift, int X, int Y)
44: {
45: if (Button != 1) return;
46:
47: if (!m_PanOperation) return;
48:
49: IEnvelope extent = m_pActiveView.ScreenDisplay.PanStop();
50:
51: if (extent != null)
52: {
53: m_pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = extent;
54: m_pActiveView.ScreenDisplay.Invalidate(null, true, (short)esriScreenCache.esriAllScreenCaches);
55: }
56: m_PanOperation = false;
57: }
58: }
编缉推荐阅读以下文章
版权与免责声明
1、本站所发布的文章仅供技术交流参考,本站不主张将其做为决策的依据,浏览者可自愿选择采信与否,本站不对因采信这些信息所产生的任何问题负责。
2、本站部分文章来源于网络,其版权为原权利人所有。由于来源之故,有的文章未能获得作者姓名,署“未知”或“佚名”。对于这些文章,有知悉作者姓名的请告知本站,以便及时署名。如果作者要求删除,我们将予以删除。除此之外本站不再承担其它责任。
3、本站部分文章来源于本站原创,本站拥有所有权利。
4、如对本站发布的信息有异议,请联系我们,经本站确认后,将在三个工作日内做出修改或删除处理。
请参阅权责声明!