MapXtrem2004经典代码:asp.net鹰眼

以下两个类对MapXtrme2004 asp.net鹰眼功能进行了完全的封装。

用法:

 1 None.gif          private   void  Page_Load( object  sender, System.EventArgs e)
 2 ExpandedBlockStart.gifContractedBlock.gif         dot.gif {
 3InBlock.gif            // 在此处放置用户代码以初始化页面
 4InBlock.gif            Overview oc = new Overview(MapControl1,MapControl2);
 5InBlock.gif        
 6InBlock.gif            if(!IsPostBack)
 7ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 8InBlock.gif                
 9InBlock.gif                
10ExpandedSubBlockEnd.gif            }

11ExpandedBlockEnd.gif        }



 

  1 ExpandedBlockStart.gif ContractedBlock.gif /**/ /* 作者:xiexiaokui
  2InBlock.gif * 时间:2005-10-18
  3InBlock.gif * 功能:asp.net鹰眼
  4ExpandedBlockEnd.gif */

  5 None.gif using  System;
  6 None.gif using  MapInfo.Web.UI.WebControls;
  7 None.gif using  MapInfo.Geometry;
  8 None.gif using  MapInfo.Styles;
  9 None.gif using  System.Drawing;
 10 None.gif using  MapInfo.Data;
 11 None.gif
 12 ExpandedBlockStart.gifContractedBlock.gif     /**/ /// <summary>
 13InBlock.gif    /// OverviewTool 的摘要说明。
 14ExpandedBlockEnd.gif    /// </summary>

 15 None.gif public   class  OverviewMapToolEventArgs:System.EventArgs
 16 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 17InBlock.gif    System.Drawing.Point[] m_points;
 18InBlock.gif    public OverviewMapToolEventArgs(System.Drawing.Point[] points)
 19ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 20InBlock.gif        this.m_points = points;
 21ExpandedSubBlockEnd.gif    }

 22InBlock.gif
 23InBlock.gif    public System.Drawing.Point[] Points
 24ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 25InBlock.gif        get
 26ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 27InBlock.gif            return m_points;
 28ExpandedSubBlockEnd.gif        }

 29InBlock.gif        set
 30ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 31InBlock.gif            m_points = value;
 32ExpandedSubBlockEnd.gif        }

 33ExpandedSubBlockEnd.gif    }

 34InBlock.gif
 35ExpandedBlockEnd.gif}

 36 None.gif
 37 None.gif public   delegate   void  OverviewMapToolEventHandler( object  sender,OverviewMapToolEventArgs e);
 38 None.gif
 39 None.gif
 40 None.gif public   class  OverviewMapTool:MapTool
 41 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 42InBlock.gif    public static readonly string Toolname = "MapInfoWebOverview";
 43InBlock.gif    //    public DPoint Point1,Point2;
 44InBlock.gif
 45InBlock.gif    string m_clientCodeSource;
 46InBlock.gif    string m_clientStartMethod;
 47InBlock.gif    string m_clientStopMethod;
 48InBlock.gif    string m_cursorUrl;
 49InBlock.gif    string m_name;
 50InBlock.gif
 51InBlock.gif
 52InBlock.gif        public event OverviewMapToolEventHandler OverviewMapToolStop;
 53InBlock.gif
 54InBlock.gif        protected void OnOverviewMapToolStop(OverviewMapToolEventArgs e)
 55ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 56InBlock.gif            if(this.OverviewMapToolStop != null)
 57InBlock.gif                this.OverviewMapToolStop(this,e);
 58ExpandedSubBlockEnd.gif        }

 59InBlock.gif
 60InBlock.gif    public OverviewMapTool()
 61ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 62InBlock.gif        this.ClientStartMethod = "MapInfoWebRectangleStart";
 63InBlock.gif        this.ClientStopMethod = "MapInfoWebRectangleStop";
 64InBlock.gif        this.Name = Toolname;
 65ExpandedSubBlockEnd.gif    }

 66InBlock.gif    public override string ClientCodeSource
 67ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 68InBlock.gif        get
 69ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 70InBlock.gif            return m_clientCodeSource;
 71ExpandedSubBlockEnd.gif        }

 72InBlock.gif        set
 73ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 74InBlock.gif            m_clientCodeSource = value;
 75ExpandedSubBlockEnd.gif        }

 76ExpandedSubBlockEnd.gif    }

 77InBlock.gif
 78InBlock.gif    public override string ClientStartMethod
 79ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 80InBlock.gif        get
 81ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 82InBlock.gif            return m_clientStartMethod;
 83ExpandedSubBlockEnd.gif        }

 84InBlock.gif        set
 85ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 86InBlock.gif            m_clientStartMethod = value;
 87ExpandedSubBlockEnd.gif        }

 88ExpandedSubBlockEnd.gif    }

 89InBlock.gif    public override string ClientStopMethod
 90ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
 91InBlock.gif        get
 92ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 93InBlock.gif            return m_clientStopMethod;
 94ExpandedSubBlockEnd.gif        }

 95InBlock.gif        set
 96ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
 97InBlock.gif            m_clientStopMethod = value;
 98ExpandedSubBlockEnd.gif        }

 99ExpandedSubBlockEnd.gif    }

100InBlock.gif    public override string CursorUrl
101ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
102InBlock.gif        get
103ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
104InBlock.gif            return m_cursorUrl;
105ExpandedSubBlockEnd.gif        }

106InBlock.gif        set
107ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
108InBlock.gif            m_cursorUrl = value;
109ExpandedSubBlockEnd.gif        }

110ExpandedSubBlockEnd.gif    }

111InBlock.gif    public override string Name
112ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
113InBlock.gif        get
114ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
115InBlock.gif            return m_name;
116ExpandedSubBlockEnd.gif        }

117InBlock.gif        set
118ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
119InBlock.gif            m_name = value;
120ExpandedSubBlockEnd.gif        }

121ExpandedSubBlockEnd.gif    }

122InBlock.gif
123InBlock.gif
124InBlock.gif    public override void Execute(string dataString, System.Collections.ArrayList selLayers, MapInfo.Mapping.Map map)
125ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
126InBlock.gif        
127InBlock.gif    //    DPoint dp1,dp2;
128InBlock.gif        System.Drawing.Point[] points = base.ExtractPoints(dataString);
129InBlock.gif    //    map.DisplayTransform.FromDisplay(points[0],out dp1);
130InBlock.gif    //    map.DisplayTransform.FromDisplay(points[1],out dp2);
131InBlock.gif    
132InBlock.gif    
133InBlock.gif        this.OnOverviewMapToolStop(new OverviewMapToolEventArgs(points));
134InBlock.gif        //    OverviewMapTool omt = (OverviewMapTool)this.MapControl2.MapTools[MapControl2.MapTools.Count-1];
135InBlock.gif        //    MapInfo.Geometry.DPoint dp1 = omt.Point1;
136InBlock.gif        //    MapInfo.Geometry.DPoint dp2 = omt.Point2;
137InBlock.gif        //    System.Drawing.Point p1,p2;
138InBlock.gif
139InBlock.gif        //    MapControl2.Map.DisplayTransform.ToDisplay(dp1,out p1);
140InBlock.gif        //    MapControl2.Map.DisplayTransform.ToDisplay(dp2,out p2);
141InBlock.gif//        if(Math.Min(Math.Abs(points[0].X-points[1].X),Math.Abs(points[0].Y-points[1].Y))<5)
142InBlock.gif//        {
143InBlock.gif//            m_mainMapControl.Map.Center = dp1;
144InBlock.gif//        }
145InBlock.gif//        else
146InBlock.gif//        {
147InBlock.gif//            MapInfo.Geometry.DRect rect = new DRect(dp1,dp2);
148InBlock.gif//            m_mainMapControl.Map.SetView(rect,m_mainMapControl.Map.GetDisplayCoordSys()); 
149InBlock.gif//        }
150InBlock.gif
151ExpandedSubBlockEnd.gif    }

152InBlock.gif
153InBlock.gif
154ExpandedBlockEnd.gif}

155 None.gif class  Overview
156 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
157InBlock.gif    
158InBlock.gif    MapInfo.Web.UI.WebControls.MapControl m_mainMapControl;
159InBlock.gif    MapInfo.Web.UI.WebControls.MapControl m_overviewMapControl;
160InBlock.gif    public Overview(MapInfo.Web.UI.WebControls.MapControl mainMapControl,MapInfo.Web.UI.WebControls.MapControl overviewMapControl)
161ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
162InBlock.gif        MainMapControl = mainMapControl;
163InBlock.gif        OverviewMapControl = overviewMapControl;
164ExpandedSubBlockEnd.gif    }

165InBlock.gif
166InBlock.gif    public MapInfo.Web.UI.WebControls.MapControl MainMapControl
167ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
168InBlock.gif        get
169ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
170InBlock.gif            return m_mainMapControl;
171ExpandedSubBlockEnd.gif        }

172InBlock.gif        set
173ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
174InBlock.gif            m_mainMapControl = value;
175InBlock.gif            m_mainMapControl.PreRender += new EventHandler(MainMapControl_PreRender);
176ExpandedSubBlockEnd.gif        }

177ExpandedSubBlockEnd.gif    }

178InBlock.gif    public MapInfo.Web.UI.WebControls.MapControl OverviewMapControl
179ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
180InBlock.gif        get
181ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
182InBlock.gif            return m_overviewMapControl;
183ExpandedSubBlockEnd.gif        }

184InBlock.gif        set
185ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
186InBlock.gif            
187InBlock.gif            
188InBlock.gif            MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("temp_overview");
189InBlock.gif            m_overviewMapControl = value;
190InBlock.gif            OverviewMapTool omt = new OverviewMapTool();
191InBlock.gif            omt.OverviewMapToolStop += new OverviewMapToolEventHandler(omt_OverviewMapToolStop);
192InBlock.gif            this.m_overviewMapControl.MapTools.Add(omt);
193InBlock.gif            this.m_overviewMapControl.MapTools.CurrentTool = omt.Name;
194InBlock.gif            if(table == null)
195ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
196InBlock.gif                
197InBlock.gif
198InBlock.gif                this.m_overviewMapControl.Map.Load(new MapInfo.Mapping.MapTableLoader(m_mainMapControl.Map.Layers.GetTableEnumerator()));
199InBlock.gif
200InBlock.gif                MapInfo.Data.TableInfo ti = MapInfo.Data.TableInfoFactory.CreateTemp("temp_overview");
201InBlock.gif                MapInfo.Data.TableSessionInfo tsi = new MapInfo.Data.TableSessionInfo();
202InBlock.gif
203InBlock.gif                table = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
204InBlock.gif
205InBlock.gif                MapInfo.Mapping.FeatureLayer fl = new MapInfo.Mapping.FeatureLayer(table);
206InBlock.gif                m_overviewMapControl.Map.Layers.Insert(0,fl);
207ExpandedSubBlockEnd.gif            }

208InBlock.gif            
209ExpandedSubBlockEnd.gif        }

210ExpandedSubBlockEnd.gif    }

211InBlock.gif    protected void MainMapControl_PreRender(object sender, EventArgs e)
212ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
213InBlock.gif        
214InBlock.gif        DRect dr = this.m_mainMapControl.Map.Bounds;
215InBlock.gif        FeatureGeometry fg = new MapInfo.Geometry.Rectangle(m_mainMapControl.Map.GetDisplayCoordSys(),dr);
216InBlock.gif        MapInfo.Styles.SimpleLineStyle sls = new MapInfo.Styles.SimpleLineStyle(new LineWidth(1,LineWidthUnit.Pixel),2,Color.Red);
217InBlock.gif        MapInfo.Styles.SimpleInterior si = new MapInfo.Styles.SimpleInterior(1);
218InBlock.gif        MapInfo.Styles.AreaStyle arst = new MapInfo.Styles.AreaStyle(sls,si);
219InBlock.gif        //    MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(arst,null,null,null);
220InBlock.gif        MapInfo.Styles.CompositeStyle cs = new MapInfo.Styles.CompositeStyle(arst);
221InBlock.gif        MapInfo.Data.Feature f = new Feature(fg,arst);
222InBlock.gif
223InBlock.gif        MapInfo.Data.Table table = MapInfo.Engine.Session.Current.Catalog.GetTable("temp_overview");
224InBlock.gif        (table as ITableFeatureCollection).Clear();
225InBlock.gif        table.InsertFeature(f);
226InBlock.gif            
227InBlock.gif        m_overviewMapControl.Map.Layers["temp_overview"].Invalidate();
228InBlock.gif        //table.Refresh();
229InBlock.gif        
230ExpandedSubBlockEnd.gif    }

231InBlock.gif
232InBlock.gif    private void omt_OverviewMapToolStop(object sender, OverviewMapToolEventArgs e)
233ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
234InBlock.gif        DPoint dp1,dp2;
235InBlock.gif        System.Drawing.Point[] points = e.Points;
236InBlock.gif        m_overviewMapControl.Map.DisplayTransform.FromDisplay(points[0],out dp1);
237InBlock.gif        m_overviewMapControl.Map.DisplayTransform.FromDisplay(points[1],out dp2);
238InBlock.gif        //    OverviewMapTool omt = (OverviewMapTool)this.MapControl2.MapTools[MapControl2.MapTools.Count-1];
239InBlock.gif        //    MapInfo.Geometry.DPoint dp1 = omt.Point1;
240InBlock.gif        //    MapInfo.Geometry.DPoint dp2 = omt.Point2;
241InBlock.gif        //    System.Drawing.Point p1,p2;
242InBlock.gif
243InBlock.gif    //    MapControl2.Map.DisplayTransform.ToDisplay(dp1,out p1);
244InBlock.gif    //    MapControl2.Map.DisplayTransform.ToDisplay(dp2,out p2);
245InBlock.gif        if(Math.Min(Math.Abs(points[0].X-points[1].X),Math.Abs(points[0].Y-points[1].Y))<5)
246ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
247InBlock.gif            m_mainMapControl.Map.Center = dp1;
248ExpandedSubBlockEnd.gif        }

249InBlock.gif        else
250ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
251InBlock.gif            MapInfo.Geometry.DRect rect = new DRect(dp1,dp2);
252InBlock.gif            m_mainMapControl.Map.SetView(rect,m_mainMapControl.Map.GetDisplayCoordSys()); 
253ExpandedSubBlockEnd.gif        }

254ExpandedSubBlockEnd.gif    }

255InBlock.gif
256ExpandedBlockEnd.gif}

257 None.gif
258 None.gif



转载于:https://www.cnblogs.com/xiexiaokui/archive/2005/10/18/257222.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值