public boolean addOverlay(Overlay overlay,KmlDocument kmlDoc){
  if (overlay == null)   return false;
  KmlFeature kmlItem;
  if (overlay instanceof GroundOverlay) {
    kmlItem=new KmlGroundOverlay((GroundOverlay)overlay);
  }
 else   if (overlay instanceof FolderOverlay) {
    kmlItem=new KmlFolder((FolderOverlay)overlay,kmlDoc);
  }
 else   if (overlay instanceof MarkerClusterer) {
    kmlItem=new KmlFolder((MarkerClusterer)overlay,kmlDoc);
  }
 else   if (overlay instanceof Marker) {
    Marker marker=(Marker)overlay;
    kmlItem=new KmlPlacemark(marker);
  }
 else   if (overlay instanceof Polygon) {
    Polygon polygon=(Polygon)overlay;
    kmlItem=new KmlPlacemark(polygon,kmlDoc);
  }
 else   if (overlay instanceof Polyline) {
    Polyline polyline=(Polyline)overlay;
    kmlItem=new KmlPlacemark(polyline,kmlDoc);
  }
 else {
    return false;
  }
  mItems.add(kmlItem);
  return true;
}

public boolean addOverlay ( Overlay overlay , KmlDocument kmlDoc ) { if ( overlay == null ) return false ; KmlFeature kmlItem ; if ( overlay instanceof GroundOverlay ) { kmlItem = new KmlGroundOverlay ( ( GroundOverlay ) overlay ) ; } else if ( overlay instanceof FolderOverlay ) { kmlItem = new KmlFolder ( ( FolderOverlay ) overlay , kmlDoc ) ; } else if ( overlay instanceof MarkerClusterer ) { kmlItem = new KmlFolder ( ( MarkerClusterer ) overlay , kmlDoc ) ; } else if ( overlay instanceof Marker ) { Marker marker = ( Marker ) overlay ; kmlItem = new KmlPlacemark ( marker ) ; } else if ( overlay instanceof Polygon ) { Polygon polygon = ( Polygon ) overlay ; kmlItem = new KmlPlacemark ( polygon , kmlDoc ) ; } else if ( overlay instanceof Polyline ) { Polyline polyline = ( Polyline ) overlay ; kmlItem = new KmlPlacemark ( polyline , kmlDoc ) ; } else { return false ; } mItems . add ( kmlItem ) ; return true ; }
converts the overlay to a kmlfeature and add it inside this . conversion from overlay subclasses to kml features is as follow : < br > folderoverlay , markerclusterer = > folder < br > marker = > point < br > polygon = > polygon < br > polyline = > linestring < br > groundoverlay = > groundoverlay < br > else , add nothing .
