Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

Regards

share|improve this question

2 Answers 2

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
share|improve this answer
    
Yes I did. In the webservice it's something like –  Phil Jul 16 '11 at 15:17
    
aoMap.AddLayer(geoFeatureLayer as IFeatureLayer); mapServerObjects.RefreshServerObjects(); but it changed nothing... –  Phil Jul 16 '11 at 15:28

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.