// build the kml according to the building mode
Kml kml = null;
KmlEncodingContext context = new KmlEncodingContext(mapContent, wms, kmz);
if (superoverlay) {
kml = new SuperOverlayNetworkLinkBuilder(context).buildKMLDocument();
} else {
kml = new SimpleNetworkLinkBuilder(context).buildKMLDocument();
}
// build the output map