# Class: Polygon

## Polygon

WPGMZA.Polygon

#### new Polygon( [row] [, enginePolygon])

  Base class for polygons. Please do not call this constructor directly. Always use createInstance rather than instantiating this class directly. Using createInstance allows this class to be externally extensible.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `row` | object | <optional> | Options to apply to this polygon.
  `enginePolygon` | object | <optional> | An engine polygon, passed from the drawing manager. Used when a polygon has been created by a drawing manager.

### Extends

- WPGMZA.MapObject

### Methods

#### <static> createInstance( [row] [, enginePolygon])

  Creates an instance of a map, please always use this function rather than calling the constructor directly.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `row` | object | <optional> | Options to apply to this polygon.
  `enginePolygon` | object | <optional> | An engine polygon, passed from the drawing manager. Used when a polygon has been created by a drawing manager.

  ##### Returns:

  An instance of WPGMZA.Polygon
  Type
    WPGMZA.Polygon

#### <static> getConstructor()

  Returns the contructor to be used by createInstance, depending on the selected maps engine.

  ##### Returns:

  The appropriate contructor
  Type
    function

#### _triggerListeners()

  Handles the logic of triggering listeners
  Inherited From:
    - WPGMZA.EventDispatcher#_triggerListeners

#### addEventListener(type, callback [, thisObject] [, useCapture])

  Adds an event listener on this object

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `type` | string |  | The event type, or multiple types separated by spaces
  `callback` | function |  | The callback to call when the event fires
  `thisObject` | object | <optional> | The object to use as "this" when firing the callback
  `useCapture` | bool | <optional> | If true, fires the callback on the capture phase, as opposed to bubble phase

  Inherited From:
    - WPGMZA.EventDispatcher#addEventListener

#### dispatchEvent(event)

  Fires an event on this object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | string | WPGMZA.Event | Either the event type as a string, or an instance of WPGMZA.Event

  Inherited From:
    - WPGMZA.EventDispatcher#dispatchEvent

#### hasEventListener(type)

  Test for listeners of type on this object

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `type` | string | The event type to test for

  Inherited From:
    - WPGMZA.EventDispatcher#hasEventListener

  ##### Returns:

  True if this object has listeners bound for the specified type
  Type
    bool

#### off()

  Alias for removeEventListener
  Inherited From:
    - WPGMZA.EventDispatcher#off
  See:
    - WPGMZA.EventDispatcher#removeEventListener

#### on()

  Alias for addEventListener
  Inherited From:
    - WPGMZA.EventDispatcher#on
  See:
    - WPGMZA.EventDispatcher#addEventListener

#### parseGeometry(string)

  Scans a string for all floating point numbers and build an array of latitude and longitude literals from the matched numbers

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `string` | string | The string to parse numbers from

  Inherited From:
    - WPGMZA.MapObject#parseGeometry

  ##### Returns:

  An array of LatLng literals parsed from the string
  Type
    array

#### removeEventListener(type [, listener] [, thisObject] [, useCapture])

  Removes event listeners from this object

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `type` | string |  | The event type to remove listeners from
  `listener` | function | <optional> | The function to remove. If omitted, all listeners will be removed
  `thisObject` | object | <optional> | Use the parameter to remove listeners bound with the same thisObject
  `useCapture` | bool | <optional> | Remove the capture phase event listener. Otherwise, the bubble phase event listener will be removed.

  Inherited From:
    - WPGMZA.EventDispatcher#removeEventListener

#### toJSON()

  Returns a JSON representation of this polygon, for serialization
  Overrides:
    - WPGMZA.MapObject#toJSON

  ##### Returns:

  A JSON object representing this polygon
  Type
    object

#### trigger()

  Alias for removeEventListener
  Inherited From:
    - WPGMZA.EventDispatcher#trigger
  See:
    - WPGMZA.EventDispatcher#removeEventListener

#### Search results