首页 / 浏览问题 / 组件GIS / 问题详情
java读取布局模板元素遍历不了或读取文字为空
42EXP 2022年08月19日
我用java读的时候遍历里面的元素获取里面的文字几何,有的能读出来,有的读出来是空白的。

还有遍历元素的时候,遍历到第9个就遍历不了了。

3 个回答

这tm文本编辑器有bug吧,我光贴图片提示我字符不够,加了字符tm说我字符太长。而且一旦不符合规则全给我清除了。什么逻辑。。。。
42EXP 2022年08月19日
public class ExportMap {
private static Workspace workspace = new Workspace();
private static MapLayout mapLayout = new MapLayout (workspace) ;
private String printMap(MapPrintParam mapPrintParam, String outPath) throws Exception {
DatasourceConnectionInfo dsInfo=DataSourceConnInfoUtil. ByMemory(;
workspace . getDatasources( . create(dsInfo);
string templatePath = mapPrintParam . getTempLatePath(;
//加载布局模枫
boolean isLoad = mapLayout . LoadT emplate ( templatePath);
if (!isLoad) 
throw new Exception(" 布局模板加载失败! ");
LayoutELements layoutELements = mapLayout . getELements();
Geometry zdDMGeom = nulL;
Geometry tfhGeom=null; 
for (int i = 0; i < layoutELements . getCount(); i++) {
booLean isMove=layoutELements . move(i);
System . out . printLn(isMove); 
Geometry geom=layoutElements . getGeometry();
if(geom. getType ()==GeometryType . GEOTEXT){
GeoText geoText=(GeoText) geom;
TextPart textPart=new TextPart();
textPart. setText("文字");
geoText. setPart( index: 0, textPart);
System . out . printLn(geoText . getText());
}
mapLayout . zoomToPaper();
mapLayout . refresh();
mapLayout. printToFile (outPath, PrintFileType .PNG, dpi: 96);
return null;

用图像识别的,我内网没法把代码复制出来,版本是supermap-iobjectsjava-10.2.1-20428-92245-win64-all-Bin

您好,请问您使用的是iObjects Java组件哪个版本呢?能读取出来的和读取出来是空白的元素有什么区别呢?如果方便的话建议您把具体代码逻辑粘贴出来,需要您这边提供足够的信息我们才能够准确的为您分析准确的原因。

希望可以帮到您。
2,153EXP 2022年08月19日
我改了文字好像出图的时候,打印出来的图片也没改变

我的布局模板

布局模板

自问自答,研究出来了,文本在ult模板中想要被读取和修改,必须要选择动态文本。

还有就是想要在代码中修改文本的值,修改完文本值后,需要把geometry对象完全替换掉,使用layoutElements.setGeometry()方法。
42EXP 2022年08月19日
...