使用.net開發基於MapX的地理信息系統-鷹眼圖模塊

VB下開發MapX比較容易,鑑於現在.net開發環境 日益流行,使用.net開發基於MapX的地理信息系統的朋友越來越多,現在我共享我平時開發的一些代碼,希望能給大家帶來一些幫助:

     鷹眼圖實際上是在導航圖上,顯示一個主窗體顯示的區域!在導航圖上添加一個臨時層,在上面添加一個矩形的圖元!

private void InitEagleReigon()
         {
             MapXLib.Feature TempFea;            
             MapXLib.StyleClass tempStyle;
            
             try
             {
                 if (this.m_eagleLayer.AllFeatures.Count == 0)//判斷該圖元是否存在
                 {
                     tempStyle = new MapXLib.StyleClass();
                     //設置矩形邊框樣式
                     tempStyle.RegionPattern = MapXLib.FillPatternConstants.miPatternNoFill;
                     tempStyle.RegionBorderColor = 255;
                     tempStyle.RegionBorderWidth = 2;
                     //在臨時圖層添加大小爲mymap的邊界的Rectangle對象
                     MapXLib.Points pnts = new MapXLib.Points();
                     pnts.AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMin, 1);
                     pnts.AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMin, 2);
                     pnts.AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMax, 3);
                     pnts.AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMax, 4);
                     TempFea = this.axMap_Eagle.FeatureFactory.CreateRegion(pnts, tempStyle);
                     m_fea = m_eagleLayer.AddFeature(TempFea, nullObject);
                     m_fea.Update(true, nullObject);                  
                 }
                 else
                 {
                     m_fea.Parts._Item(1).RemoveAll();
                     m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMin, 1);
                     m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMin, 2);
                     m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMax, axMap_Full.CtlBounds.YMax, 3);
                     m_fea.Parts._Item(1).AddXY(axMap_Full.CtlBounds.XMin, axMap_Full.CtlBounds.YMax, 4);
                     m_fea.Update(true, nullObject);                   
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("InitEagleReigon:" + ex.Message);
             }
         }

#region 鷹眼功能模塊
         private void axMap_Eagle_MouseDownEvent(object sender, AxMapXLib.CMapXEvents_MouseDownEvent e)
         {
             double MapX=0.0;
             double MapY=0.0;
             IsMouseDown = true;
             axMap_Eagle.ConvertCoord(ref e.x, ref e.y, ref MapX, ref MapY, MapXLib.ConversionConstants.miScreenToMap);
             this.axMap_Full.CenterX = MapX;
             this.axMap_Full.CenterY = MapY;
         
         }
         private void axMap_Eagle_MouseMoveEvent(object sender, AxMapXLib.CMapXEvents_MouseMoveEvent e)
         {
             if (IsMouseDown)
             {
                 double MapX = 0.0;
                 double MapY = 0.0;
                 axMap_Eagle.ConvertCoord(ref e.x, ref e.y, ref MapX, ref MapY, MapXLib.ConversionConstants.miScreenToMap);
                 this.axMap_Full.CenterX = MapX;
                 this.axMap_Full.CenterY = MapY;
             }
         }
         private void axMap_Eagle_MouseUpEvent(object sender, AxMapXLib.CMapXEvents_MouseUpEvent e)
         {
             IsMouseDown = false;
         }
         private void axMap_Full_MapViewChanged(object sender, EventArgs e)
         {
             if (IsEndInit)
                 InitEagleReigon();//初始化eagle或者根據FullMap的可視改變改變eagle的大小            
         }
         #endregion
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章