public final class

Polygon

extends Object
java.lang.Object
   ↳ com.amazon.geo.mapsv2.model.Polygon

Class Overview

A polygon overlay that can be drawn on the map. A Polygon is a list of three or more points with line segments drawn between each consecutive point, and a line segment that closes the shape drawn from the first point to the last point. A valid Polygon is filled in with its fill color. A Polygon can also have holes, which are regions inside the shape that are not filled in.

Obtain a Polygon by creating a PolygonOptions object with the initial properties and then passing it to addPolygon(PolygonOptions).

You can change the properties of the Polygon using the setter methods after the Polygon is created. Note that all getter and setter methods must be called on the main thread or an IllegalStateException is thrown.

A valid Polygon must have at least three unique vertices such that none of its line segments overlap. All added holes must also be valid polygons that do not overlap with each other, and all holes must be completely contained within the border of the Polygon. An invalid Polygon is still drawn, but is not filled in with the fill color.

Summary

Public Constructors
Polygon(IPolygonDelegate delegate)
Public constructor.
Public Methods
boolean equals(Object obj)
int getFillColor()
Gets the fill color of this Polygon.
List<List<LatLng>> getHoles()
Gets a list of the holes that have been added to this Polygon.

Holes are not supported in Amazon Maps API v2.5.

String getId()
Gets the unique ID for this Polygon.
List<LatLng> getPoints()
Gets a list of the geographic points that comprise the vertices of this Polygon.
int getStrokeColor()
Gets the stroke color of this Polygon.
float getStrokeWidth()
Gets the stroke width of this Polygon.
float getZIndex()
Gets the z-index of this Polygon.
int hashCode()
boolean isGeodesic()
Retrieves a boolean value indicating whether the Polygon line segments are drawn as geodesic (curved to correspond to the shortest path between two points on the surface of the Earth) or as straight lines.

Geodesic is not supported in Amazon Maps API v2.5

boolean isVisible()
Retrieves a boolean value indicating whether the Polygon is visible or hidden.
void remove()
Removes this Polygon from the map.
void setFillColor(int color)
Sets the fill color in ARGB format.
void setGeodesic(boolean geodesic)
Sets whether the line segments of this Polygon are drawn geodesic or non-geodesic.

Geodesic is not supported in Amazon Maps API v2.5

void setHoles(List<? extends List<LatLng>> holes)
Sets the holes in this Polygon.

Holes are not supported in Amazon Maps API v2.5.

void setPoints(List<LatLng> points)
Sets the vertices of this Polygon.
void setStrokeColor(int color)
Sets the stroke color in ARGB format.
void setStrokeWidth(float width)
Sets the stroke width of this Polygon's outline in screen pixels.
void setVisible(boolean visible)
Sets the visibility of the Polygon.
void setZIndex(float zIndex)
Sets the z-index of the Polygon.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Polygon (IPolygonDelegate delegate)

Public constructor. Instead of using this constructor, use AmazonMap.addPolygon(PolygonOptions) to create a Polygon.

Public Methods

public boolean equals (Object obj)

public int getFillColor ()

Gets the fill color of this Polygon.

Returns
  • The fill color of this polygon in ARGB format. See Color for more details.

public List<List<LatLng>> getHoles ()

Gets a list of the holes that have been added to this Polygon. Holes are automatically closed so each hole may not be equal to holes added with addHole(Iterable) or setHoles(List).

The returned list is a copy, so any subsequent changes to the holes are not reflected in this list, and any changes to this list do not change the appearance of the Polygon. To update the holes, use setHoles(List).

Holes are not supported in Amazon Maps API v2.5.

Returns
  • A list of holes in this Polygon. Each hole is represented as a list of LatLng objects.

public String getId ()

Gets the unique ID for this Polygon. The ID is unique for all Polygon objects currently added to the map. This method may be called on a background thread.

Returns
  • This Polygon's ID as a String.

public List<LatLng> getPoints ()

Gets a list of the geographic points that comprise the vertices of this Polygon. Each point in the list is represented by a LatLng. The Polygon is automatically closed, so the returned list may not be equal to the points added with PolygonOptions or set with setPoints(List).

The returned list is a copy, so any subsequent changes to the vertices of the Polygon are not reflected in this list, and any changes to this list do not change the appearance of the Polygon. To update the points of the Polygon, use setPoints(List) .

Returns
  • A list of LatLng objects representing the vertices for this Polygon.

public int getStrokeColor ()

Gets the stroke color of this Polygon.

Returns
  • This Polygon's stroke color in ARGB format. See Color for more details.

public float getStrokeWidth ()

Gets the stroke width of this Polygon.

Returns
  • This Polygon's stroke width in screen pixels.

public float getZIndex ()

Gets the z-index of this Polygon.

Returns
  • This Polygon's z-index.

public int hashCode ()

public boolean isGeodesic ()

Retrieves a boolean value indicating whether the Polygon line segments are drawn as geodesic (curved to correspond to the shortest path between two points on the surface of the Earth) or as straight lines.

Geodesic is not supported in Amazon Maps API v2.5

Returns
  • true if each segment is drawn geodesic, or false if each segment is drawn as a straight line.

public boolean isVisible ()

Retrieves a boolean value indicating whether the Polygon is visible or hidden.

Returns
  • true if this Polygon is visible, or false if it is hidden.

public void remove ()

Removes this Polygon from the map. After calling this method, calling other methods on the object has no effect on the appearance of the map.

public void setFillColor (int color)

Sets the fill color in ARGB format. Fill color is the color drawn inside the Polygon. Holes are not filled in. To draw no fill, use TRANSPARENT. The default value is TRANSPARENT.

Parameters
color The color in ARGB format. See Color for more details.

public void setGeodesic (boolean geodesic)

Sets whether the line segments of this Polygon are drawn geodesic or non-geodesic. The default is false to draw straight lines.

Geodesic line segments are drawn as a curve that corresponds to the shortest path between two points on the surface of the Earth. The curve is drawn assuming that the Earth is a sphere.

Non-geodesic line segments are drawn as straight lines on top of the map's projection.

Geodesic is not supported in Amazon Maps API v2.5

Parameters
geodesic true to draw geodesic line segments, or false to draw straight lines on the map.

public void setHoles (List<? extends List<LatLng>> holes)

Sets the holes in this Polygon. The list of holes passed to this method is copied, so modifying the contents of holes after calling this method has no effect. Each hole provided in the list of holes is represented by a list of LatLng objects.

Holes are automatically closed, so only unique vertices need to be included in the list of LatLng objects. Although manually closing the holes does not make the Polygon invalid, it is unnecessary.

Holes are not supported in Amazon Maps API v2.5.

Parameters
holes A list of holes. Each hole is represented as a list of LatLng objects representing the vertices of the hole. Must not be null. Use an empty list to remove all holes.

public void setPoints (List<LatLng> points)

Sets the vertices of this Polygon. The list of points passed to this method is copied, so modifying the contents of points after calling this method has no effect.

The Polygon is automatically closed, so only unique vertices need to be included in the list of LatLng objects. Although manually closing the Polygon does not make it invalid, it is unnecessary.

Parameters
points A list of LatLng objects that represent the vertices of this Polygon. Must not be null or empty.

public void setStrokeColor (int color)

Sets the stroke color in ARGB format. Stroke color is the color of the Polygon's outline. To draw no outline, use TRANSPARENT. The default value is is BLACK.

Parameters
color The color in ARGB format. See Color for more details.

public void setStrokeWidth (float width)

Sets the stroke width of this Polygon's outline in screen pixels. Must be zero or greater. No outline is drawn if stroke width is set to zero. The default value is 10.

Parameters
width The stroke width in screen pixels.
Throws
IllegalArgumentException if width is less than zero.

public void setVisible (boolean visible)

Sets the visibility of the Polygon. If false, the Polygon is hidden, but all state is preserved. The default value is true.

Parameters
visible true to make this Polygon visible, or false to make it hidden.

public void setZIndex (float zIndex)

Sets the z-index of the Polygon. Z-index determines the order in which overlays are drawn. Overlays with higher indices are drawn over overlays with lower indices. Overlays with the same z-index are drawn in an arbitrary order.

Overlays that are affected by z-index include GroundOverlay, TileOverlay, Circle, Polyline, and Polygon.

Marker overlays are not affected by the z-index of other overlays.

The default value is zero.

Parameters
zIndex The z-index.

public String toString ()