1. 功能簡介ide
符號選擇器能夠根據不一樣的需求進行改變圖層的符號形狀以及顏色,下面基於PIE SDK介紹如何使用符號選擇器。spa
2. 功能實現說明code
第一步視頻 |
加載圖層blog |
第二步教程 |
判斷圖層的符號類型接口 |
第三步ip |
對話框裏顯示當前對應符號類型的符號界面ci |
第四步it |
將選中的符號進行渲染,並顯示 |
接口/類 |
方法/屬性 |
說明 |
PIE.AxControls. SymbolSelectorDialog |
Symbol |
獲取或設置符號 |
GeometryType |
GetGeomType() |
獲取類型 |
IFeatureUniqueValueRender |
DefaultSymbol |
獲取或設置默認符號 |
IFeatureLayer |
Render |
獲取或設置矢量圖層渲染 |
項目路徑 |
百度雲盤地址下/PIE示例程序/12.通用功能/04符號樣式選擇器 |
數據路徑 |
百度雲盤地址下/PIE示例數據/矢量數據/Shape/省級行政區.shp |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/12.通用功能/04符號樣式選擇器.avi |
示例代碼 |
|
1 /// <summary> 2 /// 打開樣式選擇器 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_OpenSymbolSelector_Click(object sender, EventArgs e) 7 { 8 SymbolSelectorDialog symbolSelectDialog = new SymbolSelectorDialog(); 9 //1.獲取要操做的圖層 10 IMap map = mapControlMain.FocusMap; 11 IFeatureLayer featureLayer = map.GetLayer(0) as IFeatureLayer; 12 //2.判斷圖層的類型 13 GeometryType geoType = featureLayer.FeatureClass.GetGeomType(); 14 ISymbol currentSymbol = null; 15 16 switch (geoType) 17 { 18 case GeometryType.GeometryPoint: 19 currentSymbol = new SimpleMarkerSymbol(); 20 break; 21 case GeometryType.GeometryPolygon: 22 currentSymbol = new SimpleFillSymbol(); 23 break; 24 case GeometryType.GeometryPolyline: 25 currentSymbol = new SimpleLineSymbol(); 26 break; 27 case GeometryType.GeometryUnknown: 28 break; 29 default: 30 break; 31 } 32 if (currentSymbol != null) 33 { 34 //3.對話框顯示當前圖層的類型符號 35 symbolSelectDialog.Symbol = currentSymbol; 36 if (symbolSelectDialog.ShowDialog() != 1) return;//判斷ok仍是取消 37 38 //4.將選中的符號進行渲染 39 ISymbol selectSymbol = symbolSelectDialog.Symbol; 40 //IFeatureRender featureRender = featureLayer.Render; 41 IFeatureUniqueValueRender render = new FeatureUniqueValueRender(); 42 render.DefaultSymbol = selectSymbol; 43 featureLayer.Render = render as IFeatureRender; 44 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 45 } 46 } |