API Docs for: 7.2
Show:

MQA.ShapeOverlay Class

Extends MQA.Component
Module: MQA

Base shape class. Constructs a new MQA.ShapeOverlay object

Constructor

MQA.ShapeOverlay

()

Properties

_curVisibility

Boolean private

Whether this shape is currently visible, for internal comparison with the public 'visible' property.

Defaults to true.

altStateFlag

Boolean protected

Set to true for the shape overlay to be in its 'alt' state.

borderWidth

Integer protected

The width of the border in pixels. Defaults to 3.

color

String protected

The hex value of the border color. Defaults to black ('#000000').

colorAlpha

Float protected

The opacity of the border (0-1). Defaults to 1.0.

fillColor

String protected

The hex value of the fill color. Defaults to black ('#000000').

fillColorAlpha

Float protected

The opacity of the fill color (0-1). Defaults to 1.0.

firesMouseEventsWhileNotVisible

Boolean protected

Whether this shape should trigger mouse events while it is not visible.

Defaults to false, as that's the behavior most people usually want. It is very surprising when a visible shape's mouse handlers don't fire because an invisible shape is above it.

This is useful for things like ellipse bounding boxes for the ShapeDrawingControl, which only activate when the cursor is over them.

key

String protected

User-defined key for this object.

maxZoomLevel

Integer protected

The maximum zoom level in which the shape overlay should display. Defaults to 18 (the highest available zoom level).

minZoomLevel

Integer protected

The minimum zoom level in which the shape overlay should display. Defaults to 2 (the lowest available zoom level).

shapePoints

Array protected

The shape points used to draw the overlay. The lat/lng values are translated into pixel placements.

visible

Boolean protected

Set to false if shape overlay should not be visible. Defaults to true.

zIndex

Object protected

zIndex - default null.

Methods

_applyZIndex

() private

Override to apply zindex changes to elements UNIMPLEMENTED

_hasValidPoints

() private

Check whether this.points can be used to render a visible shape.

Private helper method introduced so our drawing module can eliminate no-size or one-point shapes added by the user.

As such, may not be satisfactory when used outside the context of the ShapeDrawingControl control.

_prefix

() private

Return an identifier with a prefix attached to it and its first letter upper-cased.

Included here for use by CanvasShapeOverlay. Not intended for general consumption.

add

()

Add the shape to the surface. Must be called to show the shape.

attrUpdated

()

Called when one of the alternate state flag based attributes is updated. UNIMPLEMENTED

createPeer

() MQA.ShapeOverlay

creates a peer

Returns <MQA.ShapeOverlay>

returns this instance

defineProperty

(
  • name
  • transformFunction
  • defaultValue
  • setTrigger
)

Inherited from MQA.Component

Dynamically define a property, complete with getters, setters, an optional transformFunction, default value and setTrigger. This method can be invoked on a function's prototype to create a permanent property for all instances.

Parameters:

  • name String

    Camel-cased property name

  • transformFunction Function

    (Optional) If defined, then the setter will filter the value to set through this function

  • defaultValue Object

    (Optional) If defined the default value to initialize immediately

  • setTrigger Function | String

    (Optional) If defined the given named trigger method will be called when the setter results in a change.

Example:

 myObj.defineProperty('myNewProp', parseInt, 0, function () { alert('myNewProp changed'); });
 myObj.setMyNewProp('1'); // Will trigger alert
 myObj.getMyNewProp();  // --> 1

 myObj.boolTrigger = function () { alert('bool changed'); };
 myObj.defineProperty('reallyBig', Boolean, false, 'boolTrigger');
 myObj.isReallyBig();   // --> false
 myObj.setReallyBig(1); // alert "bool changed"
 myObj.isReallyBig();   // --> true

dispose

()

Inherited from MQA.Component

Dispose

element

()

element

Returns

this Element

getActValue

() Object

Returns the actual value for a property, adjusted for the altStateFlag

Returns <Object>

value of state

getAltStateFlag

() Boolean

Get whether the shape overlay is in its 'alt' state.

Returns <Boolean>

getBorderWidth

() Integer

Get the width of the border in pixels.

Returns <Integer>

getColor

() String

Get the hex value of the border color. Starts as black ('#000000').

Returns <String>

getColorAlpha

() Float

Get the opacity of the border (0-1).

Returns <Float>

getFillColor

() String

Get the hex value of the fill color.

Returns <String>

getFillColorAlpha

() Float

Get the opacity of the fill color (0-1).

Returns <Float>

getFiresMouseEventsWhileNotVisible

() Boolean

Get whether this shape triggers mouse events while it is not visible.

Starts as false, as that's the behavior most people usually want. It is very surprising when a visible shape's mouse handlers don't fire because an invisible shape is above it.

This is useful for things like the ellipse bounding boxes in the ShapeDrawingControl, which only activate if the cursor is over them.

Returns <Boolean>

getKey

() String

Get user-defined key for this object.

Returns <String>

getMaxZoomLevel

() Integer

Get the maximum zoom level in which the shape overlay should display. Starts at 18 (the highest available zoom level).

Returns <Integer>

getMinZoomLevel

() Integer

Get the minimum zoom level in which the shape overlay should display. Starts at 2 (the lowest available zoom level).

Returns <Integer>

getShapePoints

() Array

Get the shape points used to draw the overlay.

Returns <Array>

getValue

(
  • pcKey
)
Mixed

Inherited from MQA.Component

Returns the value if it exists, undefined otherwise.

Parameters:

  • pcKey String

    The property name of the value to get.

Returns <Mixed>

The value of the specified property name. If the specified property does not exist, undefined is returned.

getVisible

() Boolean

Get set to false if shape overlay should not be visible. Starts as true.

Returns <Boolean>

getZIndex

() Object

Get zIndex - starts as null.

Returns <Object>

init

(
  • name
  • wireEvent
)

Initialize this ShapeOverlay.

Parameters:

layerInit

(
  • layer
  • map
)

Initializes Layer

Parameters:

remove

()

remove

resetAttributes

()

Re-applies all attributes

resetTransform

()

resetTransform

setAltStateFlag

(
  • altStateFlag
)

Pass true for the shape overlay to be in its 'alt' state.

Parameters:

setBorderWidth

(
  • borderWidth
)

Set the width of the border in pixels. Starts at 3.

Parameters:

  • borderWidth Integer

setColor

(
  • color
)

Set the hex value of the border color. Starts as black ('#000000').

Parameters:

setColorAlpha

(
  • colorAlpha
)

Set the opacity of the border (0-1). Starts at 1.0.

Parameters:

  • colorAlpha Float

setFillColor

(
  • fillColor
)

Set the hex value of the fill color. Starts as black ('#000000').

Parameters:

setFillColorAlpha

(
  • fillColorAlpha
)

Set the opacity of the fill color (0-1). Starts as 1.0.

Parameters:

  • fillColorAlpha Float

setFiresMouseEventsWhileNotVisible

(
  • shouldFireEvents
)

Set whether this shape triggers mouse events while it is not visible. Starts as false

Pass true to make overlays like ellipse bounding boxes in the ShapeDrawingControl, which only activate if the cursor is over them.

Parameters:

setKey

(
  • key
)

Set the user-defined key for this object.

Parameters:

setMaxZoomLevel

(
  • maxZoomLevel
)

Set the maximum zoom level in which the shape overlay should display. Starts at 18 (the highest available zoom level).

Parameters:

  • maxZoomLevel Integer

setMinZoomLevel

(
  • minZoomLevel
)

Set the minimum zoom level in which the shape overlay should display. Starts at 2 (the lowest available zoom level).

Parameters:

  • minZoomLevel Integer

setShapePoints

(
  • shapePoints
)

Sets the shapepoints and creates the actual shape. Currenly only accepts a string formated as lat,lng,lat,lng..etc

Parameters:

  • shapePoints String

    "latitude,longitude,latitude,longitude"

setValue

(
  • pcKey
  • pcValue
)
Boolean

Inherited from MQA.Component

Sets the specified key to the specified value.

Parameters:

  • pcKey String

    The key to the property

  • pcValue Mixed

    The value to set the property to.

Returns <Boolean>

true if the key exists and is set successfully, otherwise false.

setValues

(
  • pcValues
)
Number

Inherited from MQA.Component

Sets multiple properties for the object.

Parameters:

  • pcValues Object

    The key:value pairs to set where "key" is the property name and "value" is the value to set.

Returns <Number>

the number of objects set successfully

setVisible

(
  • visible
)

Pass false if shape overlay should not be visible. Starts as true.

Parameters:

setZIndex

(
  • zIndex
)

Set zIndex - starts as null. Triggers _applyZIndex when called.

Parameters:

updateProperties

(
  • [options]
)

Updates the shapes properties using an object

Parameters:

  • [options] Object optional
    • [color] String optional

      e.g. "#037eab"

    • [colorAlpha] Number optional

      e.g. 1

    • [borderWidth] Number optional

      e.g. 2

    • [fillColor] String optional

      e.g. "#399abd"

    • [fillColorAlpha] Number optional

      e.g. 0.20

    • [zIndex] Number optional

      e.g. 1000

updateVisibility

()

Called when one of the visibility related properties changes.