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
GetMapRequest requestCopy = (GetMapRequest) request.clone();
requestCopy.setBbox(null);
String style = i < styles.size() ? styles.get(i).getName() : null;
String href = WMSRequests.getGetMapUrl(requestCopy, layers.get(i).getName(), i, style,
null, null);
try {
// WMSRequests.getGetMapUrl returns a URL encoded query string, but GoogleEarth
// 6 doesn't like URL encoded parameters. See GEOS-4483
href = URLDecoder.decode(href, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
Link url = nl.createAndSetUrl();
url.setHref(href);
url.setViewRefreshMode(ViewRefreshMode.ON_STOP);
url.setViewRefreshTime(1);
url.setViewBoundScale(1);
}