You are on page 1of 14

Polygon

public final class Polygon extends Object

A polygon on the earth's surface. A polygon can be convex or concave, it may span the
180 meridian and it can have holes that are not filled in. It has the following properties:

Outline

The outline is specified by a list of vertices in clockwise or counterclockwise


order. It is not necessary for the start and end points to coincide; if they do not,
the polygon will be automatically closed. Line segments are drawn between
consecutive points in the shorter of the two directions (east or west).

Holes

A hole is a region inside the polygon that is not filled. A hole is specified in
exactly the same way as the outline. A hole must be fully contained within the
outline. Multiple holes can be specified, however overlapping holes are not
supported.

Stroke Width

Line segment width in screen pixels. The width is constant and independent of
the camera's zoom level. The default value is 10.

Stroke Color

Line segment color in ARGB format, the same format used by Color. The default
value is black (0xff000000).

Stroke Joint Type

The joint type defines the shape to be used when joining adjacent line segments
at all vertices of the polygon's outline. See JointType for supported joint types.
The default value is DEFAULT.

Stroke pattern

Solid (default, represented by null) or a sequence of PatternItem objects to be


repeated along the polygon's outline. Available PatternItem types: Gap (defined
by gap length in pixels), Dash (defined by stroke width and dash length in pixels)
and Dot (circular, centered on the polygon's outline, diameter defined by stroke
width in pixels).
Fill Color

Fill color in ARGB format, the same format used by Color. The default value is
transparent (0x00000000). If the polygon geometry is not specified correctly (see
above for Outline and Holes), then no fill will be drawn.

Z-Index

The order in which this polygon is drawn with respect to other overlays,
including Polylines, Circles,GroundOverlays and TileOverlays, 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 value is arbitrary. The
default is 0.

Visibility

Indicates if the polygon is visible or invisible, i.e., whether it is drawn on the map.
An invisible polygon is not drawn, but retains all of its other properties. The
default is true, i.e., visible.

Geodesic status

Indicates whether the segments of the polygon should be drawn as geodesics,


as opposed to straight lines on the Mercator projection. A geodesic is the
shortest path between two points on the Earth's surface. The geodesic curve is
constructed assuming the Earth is a sphere

Clickability

If you want to handle events fired when the user clicks the polygon, set this
property to true. You can change this value at any time. The default is false. If
this property is set to true, your app will receive notifications to
the GoogleMap.OnPolygonClickListener registered
through setOnPolygonClickListener(GoogleMap.OnPolygonClickListener
).

Tag

An Object associated with the polygon. For example, the Object can contain


data about what the polygon represents. This is easier than storing a
separate Map<Polygon, Object>. As another example, you can associate
a String ID corresponding to the ID from a data set. Google Maps Android API
neither reads nor writes this property.
Methods in this class must be called on the Android UI thread. If not,
an IllegalStateException will be thrown at runtime.

Public Method Summary

boolean equals(Object other)
Tests if this Polygon is equal to another.
int getFillColor()
Gets the fill color of this polygon.
List<List<LatLng>> getHoles()
Returns a snapshot of the holes of this polygon at this time .
String getId()
Gets this polygon's id.
List<LatLng> getPoints()
Returns a snapshot of the vertices of this polygon at this time .
int getStrokeColor()
Gets the stroke color of this polygon.
int getStrokeJointType()
Gets the stroke joint type used at all vertices of the polygon's outline.
List<PatternItem> getStrokePattern()
Gets the stroke pattern of this polygon's outline.
float getStrokeWidth()
Gets the stroke width of this polygon.
Object getTag()
Gets the tag for the polygon.
float getZIndex()
Gets the zIndex of this polygon.
int hashCode()
boolean isClickable()
Gets the clickability of the polygon.
boolean isGeodesic()
Gets whether each segment of the line is drawn as a geodesic or not.
boolean isVisible()
Gets the visibility of this polygon.
void remove()
Removes the polygon from the map.
void setClickable(boolean clickable)
Sets the clickability of the polygon.
void setFillColor(int color)
Sets the fill color of this polygon.
void setGeodesic(boolean geodesic)
Sets whether to draw each segment of the line as a geodesic or not.
void setHoles(List<? extends List<LatLng>> holes)
Sets the holes of this polygon.
void setPoints(List<LatLng> points)
Sets the points of this polygon.
void setStrokeColor(int color)
Sets the stroke color of this polygon.
void setStrokeJointType(int jointType)
Sets the joint type for all vertices of the polygon's outline.
void setStrokePattern(List<PatternItem> pattern)
Sets the stroke pattern of the polygon's outline.
void setStrokeWidth(float width)
Sets the stroke width of this polygon.
void setTag(Object tag)
Sets the tag for the polygon.
void setVisible(boolean visible)
Sets the visibility of this polygon.
void setZIndex(float zIndex)
Sets the zIndex of this polygon.

PolygonOptions
public final class PolygonOptions extends AbstractSafeParcelable

Defines options for a polygon.

Public Method Summary

PolygonOptions add(LatLng... points)
Adds vertices to the outline of the polygon being built.
PolygonOptions add(LatLng point)
Adds a vertex to the outline of the polygon being built.
PolygonOptions addAll(Iterable<LatLng> points)
Adds vertices to the outline of the polygon being built.
PolygonOptions addHole(Iterable<LatLng> points)
Adds a hole to the polygon being built.
PolygonOptions clickable(boolean clickable)
Specifies whether this polygon is clickable.
PolygonOptions fillColor(int color)
Specifies the polygon's fill color, as 32-bit ARGB.
PolygonOptions geodesic(boolean geodesic)
Specifies whether to draw each segment of this polygon as a geodesic.
int getFillColor()
Gets the fill color set for this PolygonOptions object.
List<List<LatLng>> getHoles()
Gets the holes set for this PolygonOptions object.
List<LatLng> getPoints()
Gets the outline set for this PolygonOptions object.
int getStrokeColor()
Gets the stroke color set for this PolygonOptions object.
int getStrokeJointType()
Gets the stroke joint type set in this PolygonOptions object for all vertices
of the polygon's outline.
List<PatternItem> getStrokePattern()
Gets the stroke pattern set in this PolygonOptions object for the polygon's
outline.
float getStrokeWidth()
Gets the stroke width set for this PolygonOptions object.
float getZIndex()
Gets the zIndex set for this PolygonOptions object.
boolean isClickable()
Gets the clickability setting for this PolygonOptions object.
boolean isGeodesic()
Gets the geodesic setting for this PolygonOptions object.
boolean isVisible()
Gets the visibility setting for this PolygonOptions object.
PolygonOptions strokeColor(int color)
Specifies the polygon's stroke color, as 32-bit ARGB.
PolygonOptions strokeJointType(int jointType)
Specifies the joint type for all vertices of the polygon's outline.
PolygonOptions strokePattern(List<PatternItem> pattern)
Specifies a stroke pattern for the polygon's outline.
PolygonOptions strokeWidth(float width)
Specifies the polygon's stroke width, in display pixels.
PolygonOptions visible(boolean visible)
Specifies the visibility for the polygon.
void writeToParcel(Parcel out, int flags)
PolygonOptions zIndex(float zIndex)
Specifies the polygon's zIndex, i.e., the order in which it will be drawn.

Polyline
public final class Polyline extends Object

A polyline is a list of points, where line segments are drawn between consecutive
points. A polyline has the following properties:

Points

The vertices of the line. Line segments are drawn between consecutive points. A
polyline is not closed by default; to form a closed polyline, the start and end
points must be the same.

Width

Line segment width in screen pixels. The width is constant and independent of
the camera's zoom level. The default value is 10.

Color

Line segment color in ARGB format, the same format used by Color. The default
value is black (0xff000000).

Start/end cap

Defines the shape to be used at the start or end of a polyline. Supported cap
types: ButtCap, SquareCap,RoundCap (applicable for solid stroke pattern)
and CustomCap (applicable for any stroke pattern). Default for both start and
end: ButtCap.

Joint type

The joint type defines the shape to be used when joining adjacent line segments
at all vertices of the polyline except the start and end vertices.
See JointType for supported joint types. The default value is DEFAULT.

Stroke pattern

Solid (default, represented by null) or a sequence of PatternItem objects to be


repeated along the line. Available PatternItem types: Gap (defined by gap
length in pixels), Dash (defined by line width and dash length in pixels)
and Dot (circular, centered on the line, diameter defined by line width in pixels).

Z-Index

The order in which this tile overlay is drawn with respect to other overlays
(including GroundOverlays,TileOverlays, Circles, 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.

Visibility

Indicates if the polyline is visible or invisible, i.e., whether it is drawn on the map.
An invisible polyline is not drawn, but retains all of its other properties. The
default is true, i.e., visible.

Geodesic status

Indicates whether the segments of the polyline should be drawn as geodesics, as


opposed to straight lines on the Mercator projection. A geodesic is the shortest
path between two points on the Earth's surface. The geodesic curve is
constructed assuming the Earth is a sphere

Clickability

If you want to handle events fired when the user clicks the polyline, set this
property to true. You can change this value at any time. The default is false. If
this property is set to true, your app will receive notifications to
the GoogleMap.OnPolylineClickListener registered
through setOnPolylineClickListener(GoogleMap.OnPolylineClickListen
er).

Tag

An Object associated with the polyline. For example, the Object can contain


data about what the polyline represents. This is easier than storing a
separate Map<Polyline, Object>. As another example, you can associate
a String ID corresponding to the ID from a data set. Google Maps Android API
neither reads nor writes this property.

Methods in this class must be called on the Android UI thread. If not,


an IllegalStateException will be thrown at runtime.

Public Method Summary

boolean equals(Object other)
Tests if this Polyline is equal to another.
int getColor()
Gets the color of this polyline.
Cap getEndCap()
Gets the cap at the end vertex of this polyline.
String getId()
Gets this polyline's id.
int getJointType()
Gets the joint type used at all vertices of the polyline except the start and end
vertices.
List<PatternItem> getPattern()
Gets the stroke pattern of this polyline.
List<LatLng> getPoints()
Returns a snapshot of the vertices of this polyline at this time .
Cap getStartCap()
Gets the cap at the start vertex of this polyline.
Object getTag()
Gets the tag for the polyline.
float getWidth()
Gets the width of this polyline.
float getZIndex()
Gets the zIndex of this polyline.
int hashCode()
boolean isClickable()
Gets the clickability of the polyline.
boolean isGeodesic()
Gets whether each segment of the line is drawn as a geodesic or not.
boolean isVisible()
Gets the visibility of this polyline.
void remove()
Removes this polyline from the map.
void setClickable(boolean clickable)
Sets the clickability of the polyline.
void setColor(int color)
Sets the color of this polyline.
void setEndCap(Cap endCap)
Sets the cap at the end vertex of this polyline.
void setGeodesic(boolean geodesic)
Sets whether to draw each segment of the line as a geodesic or not.
void setJointType(int jointType)
Sets the joint type for all vertices of the polyline except the start and end
vertices.
void setPattern(List<PatternItem> pattern)
Sets the stroke pattern of the polyline.
void setPoints(List<LatLng> points)
Sets the points of this polyline.
void setStartCap(Cap startCap)
Sets the cap at the start vertex of this polyline.
void setTag(Object tag)
Sets the tag for the polyline.
void setVisible(boolean visible)
Sets the visibility of this polyline.
void setWidth(float width)
Sets the width of this polyline.
void setZIndex(float zIndex)
Sets the zIndex of this polyline.

PolylineOptions
public final class PolylineOptions extends AbstractSafeParcelable

Defines options for a polyline.

Public Method Summary

PolylineOptions add(LatLng... points)
Adds vertices to the end of the polyline being built.
PolylineOptions add(LatLng point)
Adds a vertex to the end of the polyline being built.
PolylineOptions addAll(Iterable<LatLng> points)
Adds vertices to the end of the polyline being built.
PolylineOptions clickable(boolean clickable)
Specifies whether this polyline is clickable.
PolylineOptions color(int color)
Sets the color of the polyline as a 32-bit ARGB color.
PolylineOptions endCap(Cap endCap)
Sets the cap at the end vertex of the polyline.
PolylineOptions geodesic(boolean geodesic)
Specifies whether to draw each segment of this polyline as a geodesic.
int getColor()
Gets the color set for this PolylineOptions object.
Cap getEndCap()
Gets the cap set for the end vertex in this PolylineOptions object.
int getJointType()
Gets the joint type set in this PolylineOptions object for all vertices except
the start and end vertices.
List<PatternItem> getPattern()
Gets the stroke pattern set in this PolylineOptions object for the polyline.
List<LatLng> getPoints()
Gets the points set for this PolylineOptions object.
Cap getStartCap()
Gets the cap set for the start vertex in this PolylineOptions object.
float getWidth()
Gets the width set for this PolylineOptions object.
float getZIndex()
Gets the zIndex set for this PolylineOptions object.
boolean isClickable()
Gets the clickability setting for this PolylineOptions object.
boolean isGeodesic()
Gets the geodesic setting for this PolylineOptions object.
boolean isVisible()
Gets the visibility setting for this PolylineOptions object.
PolylineOptions jointType(int jointType)
Sets the joint type for all vertices of the polyline except the start and end
vertices.
PolylineOptions pattern(List<PatternItem> pattern)
Sets the stroke pattern for the polyline.
PolylineOptions startCap(Cap startCap)
Sets the cap at the start vertex of the polyline.
PolylineOptions visible(boolean visible)
Specifies the visibility for the polyline.
PolylineOptions width(float width)
Sets the width of the polyline in screen pixels.
void writeToParcel(Parcel out, int flags)
PolylineOptions zIndex(float zIndex)
Specifies the polyline's zIndex, i.e., the order in which it will be drawn.

TileOverlay
public final class TileOverlay extends Object

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.

Z-Index

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.

Transparency

Transparency of the tile 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 (for
example, if a pixel in the bitmap has an alpha value of 200 and you specify the
transparency of the tile overlay as 0.25, then the pixel will be rendered on the screen
with an alpha value of 150). Specification of this property is optional and the default
transparency is 0 (opaque).

Visibility

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 xvalues of the tile coordinates range from 0 to 2 N - 1 and
increase from west to east and the y values range from 0 to 2N - 1 and increase from
north to south.

Public Method Summary

void clearTileCache()
Clears the tile cache so that all tiles will be requested again from the TileProvider.
boolean equals(Object other)
Tests if this TileOverlay is equal to another.
boolean getFadeIn()
Gets whether the overlay tiles should fade in.
String getId()
Gets this tile overlay's id.
float getTransparency()
Gets the transparency of this tile overlay.
float getZIndex()
Gets the zIndex of this tile overlay.
int hashCode()
boolean isVisible()
Gets the visibility of this tile overlay.
void remove()
Removes this tile overlay from the map.
void setFadeIn(boolean fadeIn)
Sets whether the overlay tiles should fade in.
void setTransparency(float transparency)
Sets the transparency of this tile overlay.
void setVisible(boolean visible)
Sets the visibility of this tile overlay.
void setZIndex(float zIndex)
Sets the zIndex of this tile overlay.
TileOverlayOptions
public final class TileOverlayOptions extends AbstractSafeParcelable

Defines options for a TileOverlay.

Public Method Summary

TileOverlayOptions fadeIn(boolean fadeIn)


Specifies whether the tiles should fade in.
boolean getFadeIn()
Gets whether the tiles should fade in.
TileProvider getTileProvider()
Gets the tile provider set for this TileOverlayOptions object.
float getTransparency()
Gets the transparency set for this TileOverlayOptions object.
float getZIndex()
Gets the zIndex set for this TileOverlayOptions object.
boolean isVisible()
Gets the visibility setting for this TileOverlayOptions object.
TileOverlayOptions tileProvider(TileProvider tileProvider)
Specifies the tile provider to use for this tile overlay.
TileOverlayOptions transparency(float transparency)
Specifies the transparency of the tile overlay.
TileOverlayOptions visible(boolean visible)
Specifies the visibility for the tile overlay.
void writeToParcel(Parcel out, int flags)
TileOverlayOptions zIndex(float zIndex)
Specifies the tile overlay's zIndex, i.e., the order in which it will be drawn
where overlays with larger values are drawn above those with lower values.

VisibleRegion
public final class VisibleRegion extends AbstractSafeParcelable

Contains the four points defining the four-sided polygon that is visible in a map's
camera. This polygon can be a trapezoid instead of a rectangle, because a camera can
have tilt. If the camera is directly over the center of the camera, the shape is
rectangular, but if the camera is tilted, the shape will appear to be a trapezoid whose
smallest side is closest to the point of view.
Field Summary

public final LatLng farLeft LatLng object that defines the far left corner of the
camera.
public final LatLng farRight LatLng object that defines the far right corner of the
camera.
public final LatLngBounds latLngBounds The smallest bounding box that includes the visible
region defined in this class.
public final LatLng nearLeft LatLng object that defines the bottom left corner of
the camera.
public final LatLng nearRight LatLng object that defines the bottom right corner of
the camera.

Public Constructor Summary

VisibleRegion(LatLng nearLeft, LatLng nearRight, LatLng farLeft, LatLng farRight, LatLngBounds l
atLngBounds)
Creates a new VisibleRegion given the four corners of the camera.

Public Method Summary

boolean equals(Object o)
Compares this VisibleRegion to another object.
int hashCode()
String toString()
void writeToParcel(Parcel out, int flags)

You might also like