Issue with MapTitle in ArcObjects Java 10.1

1630
4
01-20-2013 04:51 AM
Highlighted
New Contributor
Hi,

In my MapViewer I want to add a MapTitle, MarkerNorthArrow, AlternatingScaleBar & ScaleText.

I am not being able to position the title correctly.

When I zoom the title disappears! but North arrow, scale bar etc remains.

I am following this http://resources.arcgis.com/en/help/arcobjects-java/concepts/engine/index.html#/How_to_interact_with...

IEnvelope env1 = new Envelope();
env1.putCoords(7, 25, 12, 20);

UID titleUID = new UID();
titleUID.setValue("esriCarto.MapTitle");
MapTitle title = new MapTitle();
title.setMapByRef(docMap);
IMapSurroundFrame titleMapSurroundFrame = docMapFrame.createSurroundFrame(titleUID, null);
String name = DEM.getName();
if (DEM.getName().contains(".")) {
name = DEM.getName().substring(0, DEM.getName().lastIndexOf("."));
}
titleMapSurroundFrame.getMapSurround().setName(name.toUpperCase());
IElement titleElement = (IElement)titleMapSurroundFrame;
titleElement.setGeometry(env1);
titleElement.activate(docActiveView.getScreenDisplay());
docGraphicsContainer.addElement(titleElement, 1);


Thanks,
Avishek
Reply
0 Kudos
4 Replies
Highlighted
Regular Contributor III
Try positioning the element with a point geometry instead of an envelope.  You can set the horizontal and vertical alignment properties on the element so that it aligns itself on the point the way you want it to.
Reply
0 Kudos
Highlighted
New Contributor
Hello Neil,

On changing it to:

Point titlePt = new Point();
titlePt.putCoords((mainEnv.getXMax() - mainEnv.getXMin())/2, mainEnv.getYMax -1);
.
.
.
titleElement.setGeometry(titlePt);


I get AutomationException: Missing raster band wavelength properties in line docGraphicContainer,addElement(titleElement,1)

I also saw that this zoom problem with the title only happens when there is a ScaleBar and/or ScaleText also added to the GraphicsContainer.

Any ideas?

Try positioning the element with a point geometry instead of an envelope.  You can set the horizontal and vertical alignment properties on the element so that it aligns itself on the point the way you want it to.
Reply
0 Kudos
Highlighted
Regular Contributor III
Sorry, I was thinking the map title was a type of text element but it isn't.  You might try using a standard text element instead of a map title.
Reply
0 Kudos
Highlighted
New Contributor
Thanks Neil,

Making it a text element solved the issue. However on different systems(screens) the Title, scale bar etc are taking up different positions. I noticed that the pagelayout bean is getting assigned a height and width (maybe it depends on the screen resolution), but I am unable to override it using pagelayout.setSize(,).

I am positioning using the height & width of the MapFrame which in turn depends on that of the pagelayout.

Any ideas?
Avishek


Sorry, I was thinking the map title was a type of text element but it isn't.  You might try using a standard text element instead of a map title.
Reply
0 Kudos