|
阅读:1063回复:2
Could not display Class breaks render.
I am developing a Windows Application by using VB.net and ArcGIS Engine 9.1. I followed the sample code from EnginDevGD document to make a window form that covers AxMapControl, AxTOCControl, and AxToolbarControl, and loaded a .mxd file in VB.net code. It ran fine. Then I tried to create a button for generating a class breaks render for one layer that existing in the .mxd file. The layer is a polygon shape file with single symbol and I would like to render it to 4 classes and show them as circle graduated symbols. I searched most of the code that I can find on internet and rewrote them to achieve this goal. When I clicked the "render" button, I didn't see any error message. However, neither AxTOCControl nor AxMapControl displayed any render symbol. I think something must be wrong in my vb.net code. Could anyone please check my code attached below? Thanks in advance.
************************************************************************************** Private Sub btnRender_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRender.Click Dim pMap As IMap pMap = AxMapControl1.Map Dim pLayer As ILayer Dim i As Integer For i = 0 To pMap.LayerCount - 1 pLayer = pMap.Layer(i) If pLayer.Name = "Produc" Then '<---the layer that is desired to be rendered pLayer = pMap.Layer(i) Dim pFlayer As IFeatureLayer pFlayer = pLayer Dim pLyr As IGeoFeatureLayer pLyr = pFlayer 'create a render and classify the data Dim pCBR As IClassBreaksRenderer pCBR = New ClassBreaksRenderer Dim ValRange As Double = 0 ValRange = MaxVal - MinVal Dim strLegendHeading As String = "" With pCBR .BreakCount = 4 If MaxVal > 100000 And MaxVal < 100000000 Then .Break(0) = CInt(MinVal / 1000) .Break(1) = CInt((MinVal + (ValRange / 4)) / 1000) .Break(2) = CInt((MinVal + (ValRange / 2)) / 1000) .Break(3) = CInt(MaxVal / 1000) strLegendHeading = "Tons in Thousands" ElseIf MaxVal > 100000000 Then .Break(0) = CInt(MinVal / 1000000) .Break(1) = CInt((MinVal + (ValRange / 4)) / 1000000) .Break(2) = CInt((MinVal + (ValRange / 2)) / 1000000) .Break(3) = CInt(MaxVal / 1000000) strLegendHeading = "Tons in Millions" Else .Break(0) = CInt(MinVal) .Break(1) = CInt(MinVal + (ValRange / 4)) .Break(2) = CInt(MinVal + (ValRange / 2)) .Break(3) = CInt(MaxVal) strLegendHeading = "Tons" End If .Field = "SumOfValue" End With Dim pColor As IRgbColor pColor = New RgbColor pColor.RGB = RGB(255, 0, 0) Dim pMarkerSym As ISimpleMarkerSymbol pMarkerSym = New SimpleMarkerSymbol Dim pSym As ISymbol Dim j As Integer 'Generate graduated symbols For j = 0 To 3 pMarkerSym.Size = (12 + (5 * j)) pMarkerSym.Color = pColor pMarkerSym.Style = esriSimpleMarkerStyle.esriSMSCircle pSym = pMarkerSym pCBR.Symbol(j) = pSym Next j pLyr.Renderer = pCBR 'Establish a heading for legend in the TOCControl Dim pLegendInfo As ILegendInfo pLegendInfo = pCBR pLegendInfo.LegendGroup(0).Heading = strLegendHeading 'redraw the TOC and the map AxTOCControl1.Update() AxMapControl1.ActiveView.Refresh() Exit For Else End If Next i End Sub ********************************************************************* |
|
|
1楼#
发布于:2006-08-13 14:08
你好,are you 老外? <img src="images/post/smile/dvbbs/em03.gif" /><img src="images/post/smile/dvbbs/em03.gif" />
|
|
|
|
2楼#
发布于:2006-08-13 23:08
<P>很抱歉,因為沒有中文鍵盤,所以直接轉貼我在 ESRI Support Center 所提出的問題,我希望能在這邊得到一些指點。</P>
<P>終於借到鍵盤了,讓我重新把問題描述一便。</P> <P>小弟正在用VB.NET 及 AE9.1 撰寫一個 WINDOWS 的應用程式。我依照 EnginDevGD 文件裏的範例程式碼來創建一個有AxMapControl, AxTOCControl, and AxToolbarControl 的 window form ,並在程式運行當中加載一個 .mxd 檔顯現在AxMapControl。整個程式運作正常。接著我試著創建一個按扭,當我按下它時可對某個已存在 .MXD 檔的 LAYER 生成 class breaks render, (該 LAYER 原始設定是The single symbol 的 POLYGON Shapefile)。 我希望能對該layer生成4個classes並用四個不同大小的圓形符號表示 (就像在ArcMap 中對layer的Symbology屬性設定為用Quantities的Graduted symbols方法來表示)。 我是參照我所能在網路上找到的程式碼並修改它们來實現這個目地l。 當我按下 "render" 鈕時,程式運行完畢,且沒有出現任何錯誤訊息。 然而, 在 AxTOCControl 及 AxMapControl 並未顯示我要的 render symbol。 我想我的vb.net 程式碼必定在那裏出錯了。 有那位大俠可簡查我的程式碼 (貼在樓上) ? 先謝謝了 !!!<BR></P> |
|