@Override
void encodeDocumentContents(Document container) {
WMSMapContent mapContent = context.getMapContent();
GetMapRequest request = context.getRequest();
Map formatOptions = request.getFormatOptions();
LookAtDecoratorFactory lookAtFactory = new LookAtDecoratorFactory();
LookAtOptions lookAtOptions = new LookAtOptions(formatOptions);
// compute the layer bounds and the total bounds
List<ReferencedEnvelope> layerBounds = new ArrayList<ReferencedEnvelope>(mapContent
.layers().size());
ReferencedEnvelope aggregatedBounds = computePerLayerQueryBounds(mapContent, layerBounds,
null);
if (aggregatedBounds != null) {
LookAt la = lookAtFactory.buildLookAt(aggregatedBounds, lookAtOptions, false);
container.setAbstractView(la);
}
final List<MapLayerInfo> layers = request.getLayers();
final List<Style> styles = request.getStyles();
for (int i = 0; i < layers.size(); i++) {
MapLayerInfo layerInfo = layers.get(i);
NetworkLink nl = container.createAndAddNetworkLink();
nl.setName(layerInfo.getName());
nl.setVisibility(true);
nl.setOpen(true);
// look at for this layer
Envelope requestBox = context.getRequestBoxWGS84();
if (requestBox != null) {
LookAt la = lookAtFactory.buildLookAt(requestBox, lookAtOptions, false);
nl.setAbstractView(la);
}
// set bbox to null so its not included in the request, google
// earth will append it for us