@Override
 public void onDraw() {
   if (googleMap == null) {
     // create as first child of raster group
     map.getRasterContext().drawGroup(null, this);
     String id = map.getRasterContext().getId(this);
     // move to first position
     Element mapDiv = DOM.getElementById(id);
     Element rasterGroup =
         DOM.getElementById(map.getRasterContext().getId(map.getGroup(RenderGroup.RASTER)));
     DOM.insertBefore(DOM.getParent(rasterGroup), mapDiv, rasterGroup);
     String graphicsId = map.getVectorContext().getId();
     googleMap =
         createGoogleMap(
             id,
             graphicsId,
             type.name(),
             showMap,
             getVerticalMargin(),
             getHorizontalMargin(),
             getVerticalAlignmentString());
   }
 }
 /**
  * Set the visibility of the Google map.
  *
  * @param visible
  * @since 1.9.0
  */
 @Api
 public void setVisible(boolean visible) {
   this.visible = visible;
   if (googleMap != null) {
     String mapsId = map.getRasterContext().getId(this);
     Element gmap = DOM.getElementById(mapsId);
     UIObject.setVisible(gmap, visible);
     if (tosGroup != null) {
       UIObject.setVisible(tosGroup, visible);
     }
     if (visible) {
       triggerResize(googleMap);
     }
   }
 }
  @Override
  public void onRemove() {
    String id = map.getRasterContext().getId(this);

    // Remove the terms of use:
    Element element = DOM.getElementById(id + "-googleAddon");
    if (element != null) {
      Element parent = DOM.getParent(element);
      parent.removeChild(element);
    }

    // Remove the Google map too:
    element = DOM.getElementById(id);
    if (element != null) {
      Element parent = DOM.getParent(element);
      parent.removeChild(element);
    }

    googleMap = null;
  }
 private void moveTosCopyRight() {
   // move the ToS and copyright to the top
   // create a div group in the graphics context
   if (tosGroup == null) {
     String graphicsId = map.getVectorContext().getId();
     Element graphics = DOM.getElementById(graphicsId);
     tosGroup = DOM.createDiv();
     tosGroup.setId(map.getID() + "-googleAddon");
     tosGroup.getStyle().setBottom(VERTICAL_MARGIN, Unit.PX);
     graphics.appendChild(tosGroup);
     UIObject.setVisible(tosGroup, visible);
   }
   String mapsId = map.getRasterContext().getId(this);
   Element gmap = DOM.getElementById(mapsId);
   if (gmap.getChildCount() > 0) {
     Node baseMap = gmap.getChild(0);
     if (baseMap.getChildCount() > 2) {
       Node copyright = baseMap.getChild(1);
       Node tos = baseMap.getChild(2);
       tosGroup.appendChild(copyright);
       tosGroup.appendChild(tos);
     }
   }
 }