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
我的布局模板
布局模板