zoukankan      html  css  js  c++  java
  • C#+arcengine10.0+SP5实现鹰眼(加载的是mdb数据库中的数据)

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using ESRI.ArcGIS.Controls;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.DataSourcesRaster;
    using DevComponents.DotNetBar;
    
    using System.Runtime.InteropServices;
    using ESRI.ArcGIS.ADF.BaseClasses;
    using ESRI.ArcGIS.ADF.CATIDs;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.Output;
    using ESRI.ArcGIS.SystemUI;
    using ESRI.ArcGIS.Display;
      private void btAddMdb_Click_1(object sender, EventArgs e)     //添加mdb数据库打开数据
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = " Personal Geodatabase(*.mdb)|*.mdb|All Files(*.*)|*.* ";
                dlg.Title = " Open PersonGeodatabase file ";
                if (dlg.ShowDialog() != DialogResult.OK) return;
                commonfun.load_Mdb(dlg.FileName, axMap);
                AddLayerToOverViewMap();   //加入地图到鹰眼里
                axMap.Refresh();
            }
    

      

     private void axMap_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)
            {        
                #region 添加鹰眼   载入地图到鹰眼控件
                AddLayerToOverViewMap();
                #endregion                   
            }
      #region 鹰眼功能
            /// <summary>
            /// 把地图加到鹰眼里的方法,
    ///该段代码摘自http://www.cnblogs.com/zya-gis/archive/2009/04/17/1438033.html,非常好用,解决了我鹰眼一直不能显示的问题
    /// </summary> private void AddLayerToOverViewMap() { axMapSmall.ClearLayers(); for (int i = 0; i < axMap.LayerCount; i++) { IObjectCopy objectcopy = new ObjectCopyClass(); object toCopyLayer = axMap.get_Layer(i); object copiedLayer = objectcopy.Copy(toCopyLayer); ILayer C = (new FeatureLayerClass()) as ILayer; object toOverwriteLayer = C; objectcopy.Overwrite(copiedLayer, ref toOverwriteLayer); axMapSmall.AddLayer(C, i); } } private void axMap_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) //绘制鹰眼矩形框 { try { //得到范围 IEnvelope pEnv = e.newEnvelope as IEnvelope; IGraphicsContainer pGraphicsContainer = axMapSmall.Map as IGraphicsContainer; IActiveView pActiveView = pGraphicsContainer as IActiveView; //在绘制新的矩形框前,清楚、清除Map对象中的任何图形元素 pGraphicsContainer.DeleteAllElements(); IRectangleElement pRectangleEle = new RectangleElementClass(); IElement pEle = pRectangleEle as IElement; pEle.Geometry = pEnv; IRgbColor pColor = new RgbColorClass(); pColor.RGB = 255; pColor.Transparency = 255; //产生一个线符号对象 ILineSymbol pOutLine = new SimpleLineSymbolClass(); pOutLine.Width = 1; pOutLine.Color = pColor; //设置颜色属性 pColor.RGB = 255; pColor.Transparency = 0; //设置填充符号的属性 IFillSymbol pFillsymbol = new SimpleFillSymbolClass(); pFillsymbol.Color = pColor; pFillsymbol.Outline = pOutLine; IFillShapeElement pFillshapEle; pFillshapEle = pEle as IFillShapeElement; pFillshapEle.Symbol = pFillsymbol; pEle = pFillshapEle as IElement; pGraphicsContainer.AddElement(pEle, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } catch (Exception ey) { } } private void axMapSmall_OnMouseDown(object sender, AxESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) //鹰眼与主 Map 控件互动 { if (this.axMapSmall.Map.LayerCount != 0) { // 按下鼠标左键移动矩形框 if (e.button == 1) { IPoint pPoint = new PointClass(); pPoint.PutCoords(e.mapX, e.mapY); IEnvelope pEnvelope = this.axMap.Extent; pEnvelope.CenterAt(pPoint); this.axMap.Extent = pEnvelope; this.axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } // 按下鼠标右键绘制矩形框 else if (e.button == 2) { IEnvelope pEnvelop = this.axMapSmall.TrackRectangle(); this.axMap.Extent = pEnvelop; this.axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } } } private void axMapSmall_OnMouseMove(object sender, AxESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e) //按下鼠标左键的时候移动矩形框,同时也改变主的图控件的显示范围 { // 如果不是左键按下就直接返回 if (e.button != 1) return; IPoint pPoint = new PointClass(); pPoint.PutCoords(e.mapX, e.mapY); this.axMap.CenterAt(pPoint); this.axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } #endregion 鹰眼功能完结

    放效果图一张:

  • 相关阅读:
    Js事件触发列表与解说(转)
    HTTP 头部解释,HTTP 头部详细分析,最全HTTP头部信息
    【转】php 数组 编码转换
    Cookie 的规范介绍
    PHP底层的运行机制与原理
    PHP为什么会被认为是草根语言?
    asp.net中读取带有加号(+)的Cookie,会自动把加号替换为空格
    git克隆某个分支到本地指定的目录中
    yq(json,yaml)格式转换工具安装和使用
    k8s中configmap的作用及使用方式
  • 原文地址:https://www.cnblogs.com/smilepeter/p/4608875.html
Copyright © 2011-2022 走看看