public final class TileOverlay extends Object
   ↳ com.google.android.gms.maps.model.TileOverlay

A Tile Overlay is a set of images which are displayed on top of the base map tiles. These tiles may be transparent, allowing you to add features to existing maps. A tile overlay has the following properties:

Tile Provider
The TileProvider provides the images that are used in the tile overlay. You must specify the tile provider before it is added to the map. The tile provider cannot be changed once it has been added; however, you can modify the behavior of the tile provider to return different images for specific coordinates. If the tiles provided by the tile provider change, you must call clearTileCache() afterwards to ensure that the previous tiles are no longer rendered.
The order in which this tile overlay is drawn with respect to other overlays (including GroundOverlays, Circles, Polylines, and Polygons but not Markers). An overlay with a larger z-index is drawn over overlays with smaller z-indices. The order of overlays with the same z-index is arbitrary. The default zIndex is 0.
Indicates if the tile overlay is visible or invisible, i.e., whether it is drawn on the map. An invisible tile overlay is not drawn, but retains all of its other properties. The default is true, i.e., visible.

You must only call methods in this class on the main thread. Failure to do so will result in an IllegalStateException.

Tile Coordinates

Note that the world is projected using the Mercator projection (see Wikipedia) with the left (west) side of the map corresponding to -180 degrees of longitude and the right (east) side of the map corresponding to 180 degrees of longitude. To make the map square, the top (north) side of the map corresponds to 85.0511 degrees of latitude and the bottom (south) side of the map corresponds to -85.0511 degrees of latitude. Areas outside this latitude range are not rendered.

At each zoom level, the map is divided into tiles and only the tiles that overlap the screen are downloaded and rendered. Each tile is square and the map is divided into tiles as follows:

  • At zoom level 0, one tile represents the entire world. The coordinates of that tile are (x, y) = (0, 0).
  • At zoom level 1, the world is divided into 4 tiles arranged in a 2 x 2 grid.
  • ...
  • At zoom level N, the world is divided into 4N tiles arranged in a 2N x 2N grid.
Note that the minimum zoom level that the camera supports (which can depend on various factors) is GoogleMap.getMinZoomLevel and the maximum zoom level is GoogleMap.getMaxZoomLevel.

The coordinates of the tiles are measured from the top left (northwest) corner of the map. At zoom level N, the x values of the tile coordinates range from 0 to 2N - 1 and increase from west to east and the y values range from 0 to 2N - 1 and increase from north to south.


 GoogleMap map; // ... get a map.
 TileProvider tileProvider; // ... create a tile provider.
 TileOverlay tileOverlay = map.addTileOverlay(
     new TileOverlayOptions().tileProvider(tileProvider));

Public Method Summary

equals(Object other)
setFadeIn(boolean fadeIn)
setVisible(boolean visible)
setZIndex(float zIndex)

Public Methods

public void clearTileCache ()

Clears the tile cache so that all tiles will be requested again from the TileProvider. The current tiles from this tile overlay will also be cleared from the map after calling this method. The API maintains a small in-memory cache of tiles. If you want to cache tiles for longer, you should implement an on-disk cache.

public boolean equals (Object other)

public boolean getFadeIn ()

Gets whether the tiles should fade in.

  • true if the tiles are to fade in; false if it is not.

public String getId ()

Gets this tile overlay's id.

public float getZIndex ()

Gets the zIndex of this tile overlay.

  • the zIndex of the tile overlay.

public int hashCode ()

public boolean isVisible ()

Gets the visibility of this tile overlay. Note that this does not return whether the tile overlay is actually within the screen's viewport, but whether it will be drawn if it is contained in the screen's viewport.

  • this tile overlay's visibility.

public void remove ()

Removes this tile overlay from the map.

public void setFadeIn (boolean fadeIn)

Sets whether the tiles should fade in.

fadeIn if true, then the tiles will fade in; if false, the tiles will not fade in.

public void setVisible (boolean visible)

Sets the visibility of this tile overlay. When not visible, a tile overlay is not drawn, but it keeps all its other properties.

visible if true, then the tile overlay is visible; if false, it is not.

public void setZIndex (float zIndex)

Sets the zIndex of this tile overlay. See the documentation at the top of this class for more information.

zIndex the zIndex of this tile overlay.