PIE SDK地圖圖層控制

 

1. 功能簡介

    地圖圖層控制就是圖層的相關操做,如地圖圖層數據的添加、刪除、移動和拖拽等功能。ide

2. 功能實現說明

2.1. 實現思路及原理說明

第一步spa

圖層添加是調用AddLayer方法將圖層添加到地圖中code

第二步視頻

圖層刪除是調用Delete方法將指定索引的圖層刪除blog

第三步教程

圖層移動是調用MoveLayerTo方法將指定的圖層移動到指定的索引位置索引

2.2 . 核心接口與方法

接口/類接口

方法/屬性ci

說明it

 

 

PIE.AxControls.MapControl

 

AddLayer

添加圖層

DeleteLayer

刪除圖層

MoveLayer

移動圖層到指定位置

PIE.Carto.LayerFactory

CreateDeFaultLayer

建立默認圖層

2.3. 示例代碼

項目路徑

百度雲盤地址下/PIE示例程序/02.地圖操做/02.地圖圖層控制

數據路徑

百度雲盤地址下/PIE示例數據/柵格數據/04.World/World.tif

視頻路徑

百度雲盤地址下/PIE視頻教程/02.地圖操做/02.地圖圖層控制.avi

示例代碼

 1        /// 添加圖層
 2         /// </summary>
 3         /// <param name="sender"></param>
 4         /// <param name="e"></param>
 5         private void btn_AddLayer_Click(object sender, EventArgs e)
 6         {
 7             //一、獲取數據路徑
 8             OpenFileDialog openFileDialog = new OpenFileDialog();
 9             openFileDialog.Title = "加載數據";
10             openFileDialog.Filter = "Shape(*.shp)|*.shp|RasterData(*.tiff)|*.tiff;*.tif";
11             if (openFileDialog.ShowDialog() != DialogResult.OK) return;
12             //二、獲取layer
13             ILayer layer = LayerFactory.CreateDefaultLayer(openFileDialog.FileName);
14             //三、添加圖層並刷新
15             mapControlMain.ActiveView.FocusMap.AddLayer(layer, 0);
16             mapControlMain.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);
17         }
18         /// <summary>
19         /// 刪除圖層
20         /// </summary>
21         /// <param name="sender"></param>
22         /// <param name="e"></param>
23         private void btn_DeleteLayer_Click(object sender, EventArgs e)
24         {
25             if (mapControlMain.FocusMap.LayerCount < 1) return;
26             //刪除索引爲0圖層
27             ILayer layer = mapControlMain.ActiveView.FocusMap.GetLayer(0);
28             mapControlMain.ActiveView.FocusMap.DeleteLayer(layer);
29         }
30 
31         /// <summary>
32         /// 移動圖層
33         /// </summary>
34         /// <param name="sender"></param>
35         /// <param name="e"></param>
36         private void btn_MoveLayer_Click(object sender, EventArgs e)
37         {           
38             if (mapControlMain.FocusMap.LayerCount < 2) return;
39             ILayer layer = mapControlMain.ActiveView.FocusMap.GetLayer(0);
40             mapControlMain.ActiveView.FocusMap.MoveLayer(layer,1);          
41         }
View Code

2.4. 示例截圖

 

相關文章
相關標籤/搜索