# Class Polygon

java.lang.Object
com.codename1.maps.MapObject
com.codename1.maps.Polygon

public final class Polygon extends MapObject
A filled, optionally stroked polygon drawn on a map. The vertices describe the outer ring; the ring is implicitly closed. Add one through `MapSurface.addPolygon(Polygon)`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Polygon()`
  Creates an empty polygon; append outer-ring vertices with `addPoint(LatLng)`.
  `Polygon(LatLng[] pts)`
  Creates a polygon with the supplied outer-ring vertices.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Polygon`
  `addPoint(LatLng point)`
  Appends an outer-ring vertex.
  `int`
  `getFillColor()`
  The fill color as 0xAARRGGBB (alpha in the high byte).
  `List`
  `getPoints()`
  The live list of outer-ring vertices (`LatLng`).
  `int`
  `getStrokeColor()`
  The stroke color as 0xRRGGBB.
  `int`
  `getStrokeWidth()`
  The stroke width in pixels (0 hides the outline).
  `boolean`
  `isVisible()`
  Whether the polygon is rendered.
  `Polygon`
  `setFillColor(int fillColor)`
  Sets the fill color as 0xAARRGGBB (alpha in the high byte).
  `Polygon`
  `setStrokeColor(int strokeColor)`
  Sets the stroke color as 0xRRGGBB.
  `Polygon`
  `setStrokeWidth(int strokeWidth)`
  Sets the stroke width in pixels (0 hides the outline).
  `Polygon`
  `setVisible(boolean visible)`
  Shows or hides the polygon.

  ### Methods inherited from class MapObject

  `equals, getId, hashCode`

  ### Methods inherited from class Object

  `clone, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Polygon

    public Polygon()
    Creates an empty polygon; append outer-ring vertices with `addPoint(LatLng)`.

  - ### Polygon

    public Polygon(LatLng[] pts)
    Creates a polygon with the supplied outer-ring vertices.

- ## Method Details

  - ### addPoint

    public Polygon addPoint(LatLng point)
    Appends an outer-ring vertex.

  - ### getPoints

    public List getPoints()
    The live list of outer-ring vertices (`LatLng`).

  - ### getFillColor

    public int getFillColor()
    The fill color as 0xAARRGGBB (alpha in the high byte).

  - ### setFillColor

    public Polygon setFillColor(int fillColor)
    Sets the fill color as 0xAARRGGBB (alpha in the high byte).

  - ### getStrokeColor

    public int getStrokeColor()
    The stroke color as 0xRRGGBB.

  - ### setStrokeColor

    public Polygon setStrokeColor(int strokeColor)
    Sets the stroke color as 0xRRGGBB.

  - ### getStrokeWidth

    public int getStrokeWidth()
    The stroke width in pixels (0 hides the outline).

  - ### setStrokeWidth

    public Polygon setStrokeWidth(int strokeWidth)
    Sets the stroke width in pixels (0 hides the outline).

  - ### isVisible

    public boolean isVisible()
    Whether the polygon is rendered.

  - ### setVisible

    public Polygon setVisible(boolean visible)
    Shows or hides the polygon.