3

I try to create a new renderer for a geo feature layer in ArcGIS 10. (My project is an asp.net based webservice) There is one solution I got from a tutorial that works, but only for a ISimpleRenderer

 // Create an ArcObjects color object with the color set to blue for use by the layer's renderer
 IRgbColor rgbColor = (IRgbColor)serverContext.CreateObject("esriDisplay.RgbColor");
 rgbColor.Red = 0;
 rgbColor.Green = 0;
 rgbColor.Blue = 210;
 // Set the symbol of the GeoFeatureLayer's renderer to use the color initialized above
 ISimpleRenderer aoSimpleRenderer = (ISimpleRenderer)geoFeatureLayer.Renderer;
 ISimpleLineSymbol simpleLineSymbol = (ISimpleLineSymbol)aoSimpleRenderer.Symbol;
 simpleLineSymbol.Color = (IColor)rgbColor;

that works fine, but only for the SimpleRenderer. What I need is the ClassBreaksRenderer. Now the problem is, that if I create a new Renderer (SimpleRenderer or ClassBreaksRenderer), set the properties and apply it to the geo feature class (geoFeatureLayer.Renderer = cRenderer as IFeatureRenderer) the map is empty and no features are rendered.

Someone has an idea?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 14, 2011 at 21:10

2 Answers 2

1

Did you remember to add the layer, refresh the map and update the contents?

e.g. (VB.NET in native Arc10)

pMxDoc.FocusMap.AddLayer pFLayer
pMxDoc.ActiveView.Refresh
pMxDoc.UpdateContents
answered Jul 14, 2011 at 21:36
2
  • Yes I did. In the webservice it's something like Commented Jul 16, 2011 at 15:17
  • aoMap.AddLayer(geoFeatureLayer as IFeatureLayer); mapServerObjects.RefreshServerObjects(); but it changed nothing... Commented Jul 16, 2011 at 15:28
1

This problem may be caused by several reasons. My advice is that you can delete the you code about rendering line by line to figure out the bug. Meanwhile, you can save the featured layer to a .lyr file and check it in ArcMap to see where the problem is. Following is the code for layer saving.

'saveFileName is the file name you choose to save, ending with suffix of ".lyr"'
If System.IO.File.Exists(saveFileName) Then 
 System.IO.File.Delete(saveFileName)
End If
Dim layerFile As ILayerFile = New LayerFileClass()
layerFile.New(saveFileName)
'pGeoFeatureLayer is the target layer which you want to figure out the problem of no display'
layerFile.ReplaceContents(pGeoFeatureLayer) 
layerFile.Save()

In addition, there are two more parctical measures which may solve your problem.

  1. Enable the map to use symbol levels to draw the layer.

    Dim symbolLevels As ISymbolLevels symbolLevels = TryCast(pGeoFeatureLayer, ISymbolLevels) symbolLevels.UseSymbolLevels = True

  2. Check whether the symbol is accessible for current drawing element. For example, if your layer consists of polylines, SimpleFillSymbol, which is the common sample in offical guidelines about ClassBreakRender, may be not suitable for rendering. Just change it to SimpleLineSymbol, and you will see the magic! In my own work, this method worked!

answered Apr 11, 2012 at 5:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.