GroundOverlay | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Methods | Inherited Methods | [Expand All]
public final class

# GroundOverlay

extends Object

java.lang.Object
↳ | com.google.android.gms.maps.model.GroundOverlay

## Class Overview

A ground overlay is an image that is fixed to a map. A ground overlay has the following properties:

Position
  There are two ways to specify the position of the ground overlay:
  - Using a location: You must provide an image of the ground overlay, a `LatLng` to which the anchor will be fixed and the width of the overlay (in meters). The anchor is, by default, 50% from the top of the image and 50% from the left of the image. This can be changed. You can optionally provide the height of the overlay (in meters). If you do not provide the height of the overlay, it will be automatically calculated to preserve the proportions of the image.
  - Using a Bounds: You must provide a `LatLngBounds` which will contain the image.
  You must specify the position of the ground overlay before it is added to the map, otherwise an `IllegalArgumentException` will be thrown when the ground overlay is added to the map. Furthermore, you must only specify the position using one of these methods in the `GroundOverlayOptions` object; otherwise an `IllegalStateException` will be thrown when specifying using a second method.
Image
  The image (as an `BitmapDescriptor`) to be used for this overlay. The image will be scaled to fit the position provided. You must specify an image before adding the ground overlay to the map; if not an `IllegalArgumentException` will be thrown when it is added to the map.
Bearing
  The amount that the image should be rotated in a clockwise direction. The center of the rotation will be the image's anchor. This is optional and the default bearing is 0, i.e., the image is aligned so that up is north.
zIndex
  The order in which this ground overlay is drawn with respect to other overlays (including `Polyline`s and `TileOverlay`s, but not `Marker`s). An overlay with a larger zIndex is drawn over overlays with smaller zIndexes. The order of overlays with the same zIndex value is arbitrary. This is optional and the default zIndex is 0.
Transparency
  Transparency of the ground overlay in the range `[0..1]` where `0` means the overlay is opaque and `1` means the overlay is fully transparent. If the specified bitmap is already partially transparent, the transparency of each pixel will be scaled accordingly (e.g. if a pixel in the bitmap has an alpha value of 200 and you specify the transparency of the ground overlay as 0.25, then the pixel will be rendered on the screen with an alpha value of 150). This is optional and the default transparency is 0 (opaque).
Visibility
  Indicates if the ground overlay is visible or invisible, i.e. whether it is drawn on the map. An invisible ground overlay is not drawn, but retains all of its other properties. This is optional and the default visibility is `true`, i.e., visible.

Methods that modify a Polyline must be called on the UI thread. If not, an `IllegalStateException` will be thrown at runtime.

### Example

     GoogleMap map = ...; // get a map.
     BitmapDescriptor image = ...; // get an image.
     LatLngBounds bounds = ...; // get a bounds
     // Adds a ground overlay with 50% transparency.
     GroundOverlay groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
         .image(image)
         .positionFromBounds(bounds)
         .transparency(0.5));

## Summary

Public Methods
boolean | equals(Object other)
float | getBearing() Gets the bearing of the ground overlay in degrees clockwise from north.
LatLngBounds | getBounds() Gets the bounds for the ground overlay.
float | getHeight() Gets the height of the ground overlay.
String | getId() Gets this ground overlay's id.
LatLng | getPosition() Gets the location of the anchored point.
float | getTransparency() Gets the transparency of this ground overlay.
float | getWidth() Gets the width of the ground overlay.
float | getZIndex() Gets the zIndex of this ground overlay.
int | hashCode()
boolean | isVisible() Gets the visibility of this ground overlay.
void | remove() Removes this ground overlay from the map.
void | setBearing(float bearing) Sets the bearing of the ground overlay (the direction that the vertical axis of the ground overlay points) in degrees clockwise from north.
void | setDimensions(float width) Sets the dimensions of the ground overlay.
void | setDimensions(float width, float height) Sets the dimensions of the ground overlay.
void | setImage(BitmapDescriptor image) Sets the image for the Ground Overlay.
void | setPosition(LatLng latLng) Sets the position of the ground overlay by changing the location of the anchored point.
void | setPositionFromBounds(LatLngBounds bounds) Sets the position of the ground overlay by fitting it to the given `LatLngBounds`.
void | setTransparency(float transparency) Sets the transparency of this ground overlay.
void | setVisible(boolean visible) Sets the visibility of this ground overlay.
void | setZIndex(float zIndex) Sets the zIndex of this ground overlay.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## Public Methods

#### public boolean equals (Object other)

#### public float getBearing ()

Gets the bearing of the ground overlay in degrees clockwise from north.

##### Returns

- the bearing of the ground overlay.

#### public LatLngBounds getBounds ()

Gets the bounds for the ground overlay. This ignores the rotation of the ground overlay.

##### Returns

- a `LatLngBounds` that contains the ground overlay, ignoring rotation.

#### public float getHeight ()

Gets the height of the ground overlay.

##### Returns

- the height of the ground overlay in meters.

#### public String getId ()

Gets this ground overlay's id. The id will be unique amongst all GroundOverlays on a map.

##### Returns

- this ground overlay's id.

#### public LatLng getPosition ()

Gets the location of the anchored point.

##### Returns

- the position on the map (a `LatLng`).

#### public float getTransparency ()

Gets the transparency of this ground overlay.

##### Returns

- the transparency of this ground overlay.

#### public float getWidth ()

Gets the width of the ground overlay.

##### Returns

- the width of the ground overlay in meters.

#### public float getZIndex ()

Gets the zIndex of this ground overlay.

##### Returns

- the zIndex of the ground overlay.

#### public int hashCode ()

#### public boolean isVisible ()

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

##### Returns

- this ground overlay's visibility.

#### public void remove ()

Removes this ground overlay from the map. After a ground overlay has been removed, the behavior of all its methods is undefined.

#### public void setBearing (float bearing)

Sets the bearing of the ground overlay (the direction that the vertical axis of the ground overlay points) in degrees clockwise from north. The rotation is performed about the anchor point.

##### Parameters

bearing | bearing in degrees clockwise from north

#### public void setDimensions (float width)

Sets the dimensions of the ground overlay. The height of the ground overlay will be calculated to preserve the proportions inherited from the bitmap.

##### Parameters

width | width in meters

#### public void setDimensions (float width, float height)

Sets the dimensions of the ground overlay. The image will be stretched (and hence may not retain its proportions) to fit these dimensions.

##### Parameters

width | width in meters
height | height in meters

#### public void setImage (BitmapDescriptor image)

Sets the image for the Ground Overlay. The new image will occupy the same bounds as the old image.

##### Parameters

image | the `BitmapDescriptor` to use for this ground overlay.

#### public void setPosition (LatLng latLng)

Sets the position of the ground overlay by changing the location of the anchored point. Preserves all other properties of the image.

##### Parameters

latLng | a `LatLng` that is the new location to place the anchor point.

#### public void setPositionFromBounds (LatLngBounds bounds)

Sets the position of the ground overlay by fitting it to the given `LatLngBounds`. This method will ignore the rotation (bearing) of the ground overlay when positioning it, but the bearing will still be used when drawing it.

##### Parameters

bounds | a `LatLngBounds` in which to place the ground overlay

#### public void setTransparency (float transparency)

Sets the transparency of this ground overlay. See the documentation at the top of this class for more information.

##### Parameters

transparency | a float in the range `[0..1]` where `0` means that the ground overlay is opaque and `1` means that the ground overlay is transparent

#### public void setVisible (boolean visible)

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

##### Parameters

visible | if `true`, then the ground overlay is visible; if `false`, it is not

#### public void setZIndex (float zIndex)

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

##### Parameters

zIndex | the zIndex of this ground overlay