API Docs for: 7.2
Show:

MQA.BasePoi Class

Extends MQA.Component
Module: MQA

Base POI library. (The standard POI MQA.Poi which is documented for the product is derived from this base POI.) A base POI is an overlay that defines the core POI behaviors:

  • Anchored at a particular lat/lng.
  • May be biased from a particular lat/lng by a specified x/y pixel distance.
  • Maintains a list of arbitrary content to be displayed at offset positions from the anchor point.
  • Contains an offset position, defining where in the content frame of reference the anchor point falls.
  • Can draw a leader-line from from the content bias point to the anchor point
  • Provides management of DOM Events on the attached content elements.

Constructor

MQA.BasePoi

()

Properties

_cnts

MQA.Collection.map private

Map of key {String} to content element. For most POIs this will be the Icon img and Shadow img. Though any valid DOM Element will work.

Each content element is extended with the following fields:

  • ofsX: Position of the anchor point relative to the upper left corner
      of the content (X)
    
  • ofsY: Position of the anchor point relative to the upper left corner
      of the content (Y)
    
  • eventGroup: The name of the event group this content element belongs
            to.  If null/empty, then events will not be hooked.
    

_pxX

Number private

Display coordinate position x

_pxY

Number private

Display coordinate position y

bias

MQA.Point

How far to offset the POI from its XY position

Example:

//Set the poi icon 25 pixels to the left
poi.setBias(new MQA.Point(-25,0));

extraFields

Map

key

String

The unique key for the POI

latLng

MQA.LatLng

The current lat/lng position of the POI

maxZoomLevel

Number

The closest in the map can be zoomed and still show the POI

minZoomLevel

Number

The farthest out the map can be zoomed and still show the POI

visible

Boolean

If true, signals for the POI to be visible on the map

Methods

_actIsVisible

() Boolean private

Return true if the POI should actually be visible. This takes into account zoom level, explicit visibility and other constraints.

Returns <Boolean>

if the POI should be visible.

_onDOMEvent

() private

Stub event for AddDOMEventProtocol

_updateBias

(
  • x
  • y
  • biasX
  • biasY
)
private

Called when the position changes in order to update the bias. If no bias is present, then biasX and biasY will be zero. The default StdPoi implementation draws leader-lines if graphics are available. Can be overridden by sub-classes to perform custom behavior.

The coordinate system is confusing: The first set of coordinates (x,y) are the display coordinates of the "anchor" point. The second set of coordinates (biasX,biasY) are the delta offsets from (x,y) where the POI coordinate space originates. The POI coordinates (0,0) correspond to display coordinates of (x+biasX, y+biasY).

The default implementation does nothing

Parameters:

_updatePosition

() private

Updates the POI position on the map based on the existing Display transform.

_updateVisibility

() Boolean private

Update the visibility of a POI's elements based on its current visibility.

Returns <Boolean>

if the POI should be visible

activateContent

(
  • poi
  • contentElt
  • eventGroup
)
private

Attach events to the content element.

Parameters:

addExtraField

(
  • key
  • value
)

Adds keyed extra fields to the POI. Removes extra field if supplied value is null.

Parameters:

  • key String

    The unique key for the extra field.

  • value Object

    The value for the unique key. If null, the key is deleted.

createPeer

()

POIs are their own peer. Defining method for Shape interface.

deactivateContent

(
  • poi
  • contentElt
)
private

Detach events from the content.

Parameters:

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

Override the dispose method of MQA.Component to cleanup after POIs. Defining method for Shape interface.

getContent

(
  • key
)
HTMLElement

Get content associated with key.

Parameters:

  • key String

    The unique key for the content.

Returns <HTMLElement>

The content element, or null if it doesn't exist.

getExtraField

(
  • key
)
Object

Retrieves value for extra field by key

Parameters:

  • key String

    the unique key for the extra field

Returns <Object>

the value stored on the POI in the key's extra field

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.

layerInit

(
  • layer
  • map
)

Initialize the layer, initialization step for display on the map. Defining method for Shape interface.

Parameters:

reapplyContent

(
  • poi
  • contentElt
)
private

Re-apply the content position and zindex based on the properties _poiOfs and _poiZ.

Parameters:

resetTransform

() private

Stub event to conform to Shape interface. for allowing the POI to reset on a Transform change.

setContent

(
  • key
  • contentElt
  • ofsX
  • ofsY
  • eventGroup
  • zindex
)

Set a content element for the given key. Only one content element may exist for a given key and the content will be replaced if set again. The content offsetX and offsetY can be set at this time. The offset is the distance from the POI's anchor point (ie. latlng if not biased or latlng+bias if biased) to the content's upper left corner.

If eventGroup is true, then DOM Events subscribed to by addDOMEvent will be captured and will be routed to the POI event handlers. If eventGroup is not specified or evaluates to false, then no events are captured for the content.

If contentElt is null, then the content is removed from the POI for that key.

Parameters:

  • key String

    The unique key for the content.

  • contentElt HTMLElement

    The content element.

  • ofsX Number

    The x offset.

  • ofsY Number

    The y offset.

  • eventGroup Boolean

    Set to true if the DOM Events should be captured.

  • zindex Number

    The z-index for the content.

setContentOffset

(
  • key
  • ofsX
  • ofsY
)

Sets the offset on an existing content element. Does nothing if the content does not exist.

Parameters:

  • key String

    The unique key for the content.

  • ofsX Number

    The x offset.

  • ofsY Number

    The y offset.

setContentVisible

(
  • key
  • visible
)

Sets the visibility of the content element. Element will only be displayed if its POI is also visible.

Parameters:

  • key String

    The unique key for the content.

  • visible Boolean

    Set to true if content should be visible.

setContentZIndex

(
  • key
  • zindex
)

Sets the z-index for the content. This will only be fully valid after the POI has been added to the document.

Parameters:

  • key String

    The unique key for the content.

  • zindex Number

    The z-index value for the content.

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