【解决办法】需要为添加图层的地图设置地图范围,可以通过设置“全幅显示本图层”的方式
Map map = new Map(workspace);
DatasetVector dataset = (DatasetVector) workspace.getDatasources().get(0).getDatasets().get(0);
LayerSettingVector layerSettingVector = new LayerSettingVector();
Layer layer = map.getLayers().add(dataset, layerSettingVector, true);
map.refresh();
map.ensureVisible(layer);
map.setLineAntialias(true);
workspace.getMaps().add("new", map.toXML());
workspace.save();
boolean b = map.outputMapToFile(filePath,ImageType.PNG, 96, dataset.getBounds(), true);