Labeling in ArcGIS Server 9.3.1

100 views
Skip to first unread message

kruisje

unread,
Jul 15, 2009, 7:45:08 AM7/15/09
to New England ArcGIS Server User Group
Hi,


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 labelling 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.

Anyone here who encountered similar problems using the new version?

The code that used to work for me is:

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

IMaplexOverposterLayerProperties maplexOP =
(IMaplexOverposterLayerProperties) ags.getContext().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(ags.getContext().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);

Hazelton, Glenn

unread,
Jul 15, 2009, 7:47:56 AM7/15/09
to ne...@googlegroups.com
Could it be maplex?
If you are publishing the mxd to a msd and serving that I know maplex
will not work in a msd format.


Glenn Hazelton, Ph.D.
MWRA GIS Manager
2 Griffin Way
Chelsea MA 02150
glenn.h...@mwra.state.ma.us
617-305-5526

Pieter Pauwels

unread,
Jul 15, 2009, 8:30:45 AM7/15/09
to ne...@googlegroups.com
Alas,

I tried out the non-maplex below, which is basically exactly the same code, but without the usage of maplex, but I don't get to see any labels either. :/
Note that this code also works on ArcGIS Server 9.2.

Thanks though...

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

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

overPoster.setNumLabelsOption(esriBasicNumLabelsOption.esriOneLabelPerName);
overPoster.setFeatureType(ags.FEATURE_TYPE_POINT);
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(ags.getContext().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);   

Hazelton, Glenn

unread,
Jul 15, 2009, 8:55:56 AM7/15/09
to ne...@googlegroups.com

Sounds like a call to tech support or a post on the developer forum

 

Glenn Hazelton, Ph.D.

MWRA GIS Manager

2 Griffin Way

Chelsea MA 02150

glenn.h...@mwra.state.ma.us

617-305-5526

Reply all
Reply to author
Forward
0 new messages