encoder.encode(kml, zip, context);
// prepare for the ground overlays
final RenderedImageMapOutputFormat pngProducer = new RenderedImageMapOutputFormat(
"image/png", wms);
final PNGMapResponse pngEncoder = new PNGMapResponse(wms);
ZipEntry images = new ZipEntry("images/");
zip.putNextEntry(images);
// write the images
WMSMapContent mapContent = context.getMapContent();
for (Entry<String, Layer> goEntry : context.getKmzGroundOverlays().entrySet()) {
String path = goEntry.getKey();
Layer mapLayer = goEntry.getValue();
// create a context for this single layer
WMSMapContent subContext = new WMSMapContent();
subContext.addLayer(mapLayer);
subContext.setRequest(mapContent.getRequest());
subContext.setMapHeight(mapContent.getMapHeight());
subContext.setMapWidth(mapContent.getMapWidth());
subContext.getViewport().setBounds(mapContent.getRenderingArea());
subContext.setBgColor(mapContent.getBgColor());
subContext.setBuffer(mapContent.getBuffer());
subContext.setContactInformation(mapContent.getContactInformation());
subContext.setKeywords(mapContent.getKeywords());
subContext.setAbstract(mapContent.getAbstract());
subContext.setTransparent(true);
// render the map
RenderedImageMap imageMap;
try {
imageMap = pngProducer.produceMap(subContext);
} finally {
subContext.dispose();
}
// write it to the zip stream
entry = new ZipEntry(path);
zip.putNextEntry(entry);
pngEncoder.write(imageMap, zip, operation);
zip.closeEntry();
}
zip.closeEntry();// close the images/ folder
//write out the icons