You are here: > ESRI Forums > arcgis server forums > Thread Replies

ArcGIS Server Forums

ArcGIS Server Java: Developing applications forum

Labeling in ArcGIS Server 9.3.1   Pieter Pauwels Jul 15, 2009
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Labeling in ArcGIS Server 9.3.1 
Author Pieter Pauwels 
Date Jul 15, 2009 
Message I was wondering wether anyone here could help me with a labeling problem in ArcGIS Server. I'm currently using ArcGIS Server version 9.3.1, Java platform, and I'm currently in the process of upgrading a 9.2 custom webapplication to version 9.3.1.

The application I wrote still works within the newest version of the framework, with the exceptance of the programmatic labeling of
features. The code below worked perfectly for labeling features in the previous version of ArcGIS Server, yet now the code yields no results whatsoever, nor are there any Java Exceptions of Errors. So the code gets executed without any errors, but it just does not put any labels on the map.

I've tried the Maplex-version and the non-Maplex, but neither of these two versions puts labels on the map... 
 
// MAPLEX
IAnnotateLayerPropertiesCollection annoProps = ((IGeoFeatureLayer) layer).getAnnotationProperties();

IMaplexOverposterLayerProperties maplexOP =
       (IMaplexOverposterLayerProperties) serverContext.createObject(MaplexOverposterLayerProperties.getClsid());

maplexOP.setCanRemoveOverlappingLabel(false);
maplexOP.setCanStackLabel(true);
maplexOP.setNeverRemoveLabel(true);
maplexOP.setPointPlacementMethod(com.esri.arcgis.carto.esriMaplexPointPlacementMethod.esriMaplexNorthOfPoint);

MaplexLabelEngineLayerProperties maplexLE =
       (MaplexLabelEngineLayerProperties) serverContext.createObject(MaplexLabelEngineLayerProperties.getClsid());

maplexLE.setOverposterLayerPropertiesByRef((IOverposterLayerProperties) maplexOP);
maplexLE.setExpression("NAME");
IFormattedTextSymbol annoSymbol = (IFormattedTextSymbol) serverContext.createObject(TextSymbol.getClsid());
annoSymbol.setSize(10);
RgbColor color = (RgbColor) serverContext.createObject(RgbColor.getClsid());
color.setRed(255);
color.setGreen(0);
color.setBlue(0);
annoSymbol.setColor((IColor) color);
Font font = new FontProxy(serverContext.createObject(SystemFont.getClsid()));
font.setName("Courier New");
font.setBold(false);
font.setItalic(false);
font.setUnderline(false);
annoSymbol.setFont(font);

maplexLE.setSymbolByRef(annoSymbol);

IAnnotateLayerProperties annoLayerProps = (IAnnotateLayerProperties) maplexLE;

annoProps.clear();
annoProps.add(annoLayerProps);
((IGeoFeatureLayer)layer).setDisplayAnnotation(true);


// NON-MAPLEX

IAnnotateLayerPropertiesCollection annoProps = ((IGeoFeatureLayer)layer).getAnnotationProperties();

IBasicOverposterLayerProperties4 overPoster =    (IBasicOverposterLayerProperties4)serverContext.createObject(BasicOverposterLayerProperties.getClsid());

overPoster.setNumLabelsOption(esriBasicNumLabelsOption.esriOneLabelPerName);
overPoster.setFeatureType(esriBasicOverposterFeatureType.esriOverposterPoint);
overPoster.setPointPlacementMethod(esriOverposterPointPlacementMethod.esriAroundPoint);
overPoster.setPointPlacementOnTop(false);

ILabelEngineLayerProperties labelEngine =     (ILabelEngineLayerProperties)serverContext.createObject(LabelEngineLayerProperties.getClsid());

labelEngine.setBasicOverposterLayerPropertiesByRef((IBasicOverposterLayerProperties)overPoster);
labelEngine.setExpression("NAME");


IFormattedTextSymbol annoSymbol = (IFormattedTextSymbol) serverContext.createObject(TextSymbol.getClsid());
annoSymbol.setSize(10);
RgbColor color = (RgbColor) serverContext.createObject(RgbColor.getClsid());
color.setRed(255);
color.setGreen(0);
color.setBlue(0);
annoSymbol.setColor((IColor) color);
Font font = new FontProxy(serverContext.createObject(SystemFont.getClsid()));
font.setName("Courier New");
font.setBold(false);
font.setItalic(false);
font.setUnderline(false);
annoSymbol.setFont(font);

labelEngine.setSymbolByRef(annoSymbol);

IAnnotateLayerProperties annoLayerProps = (IAnnotateLayerProperties) labelEngine;
annoLayerProps.setDisplayAnnotation(true);
annoLayerProps.setLabelWhichFeatures(esriLabelWhichFeatures.esriVisibleFeatures);

annoProps.clear();
annoProps.add(annoLayerProps);
((IGeoFeatureLayer)layer).setDisplayAnnotation(true);