Class: Marker

OM.style. Marker


new Marker(config)

This class represents a Marker or symbol style that can be applied to geometry features, typical points.

For example, the following code can be used to create a simple marker style based on the Oracle logo:

var myMarker = new OM.style.Marker({src:"http://www.oracleimg.com/us/assets/oralogo-small.gif"});
Parameters:
Name Type Description
config Object

A configuration object for the marker. It can have the following attributes:


  • styleName {String} A style name

  • width {float} The marker width

  • height {float} The marker height

  • xOffset {int} The horizontal offset in pixels. Optional.
    When specified, the marker will be shifted horizontally. A positive value means shift towards the right of the screen.

  • yOffset {int} vThe ertical offset in pixels. Optional.
    When specified, the marker will be shifted vertically. A positive value means shift downward and negative value upward.

  • lengthUnit {String} The size unit. Optional.
    The value can be "pixel", "meter", "kilometer", "feet", or "mile". Default value is "pixel".

  • src {String} The marker image URL. Optional. Either src or vectorDef should be specified.

  • textStyle {OM.style.Text} The text style will apply to the text on marker feature.

  • textOffset {Object} The text offset, like {x:15, y:15}.

  • vectorDef {Array} Defines the vector marker. It is an array of vector shapes.
    Each array element can have the following properties:

    • shape {Object} The shape definition object of the vector marker.
      It has the following attributes:

      • type {String} The type of the vector shape. Valid values are "circle", "path" or "rectangle".

      • coords {Array} An array of coordinates (numbers) for the shape type "path" only.

      • cx {float} The circle's center X ordinate. For "circle" only.

      • cy {float} The circle's center Y ordinate. For "circle" only.

      • x {float} The minimum X ordinate for the shape type "rectangle" only.

      • y {float} The minimum Y ordinate for the shape type "rectangle" only.

      • width {float} The width. Valid for shape types "circle" and "rectangle" only.

      • height {float} The height. Valid for shape types "circle" and "rectangle" only.

      • scale {float} The scale. Valid for shape type "path" only.




    • style {Object} The style definition. It has these attributes:

      • stroke {String} The stroke color in rgb, i.e. in the format "#rrggbb".

      • strokeThickness (float} The stroke width.

      • strokeOpacity {float} The stroke opacity. A value between 0 (transparent) and 1 (opaque).

      • fill {String} The fill color in rgb, i.e. in the format "#rrggbb".

      • fillOpacity {float} The fill opacity. A value between 0 and 1.

      • visibility (Boolean} Whether the marker is visible (when true) or not (when false) on initialization.

      • filter {OM.visualfilter.VisualFilter} The visual effect to apply if any. Optional.






  • nullFillSrc {String} An optional image source to use as a fill pattern when no fill is set up for the marker.

Returns:

An instance of OM.style.Marker

Extends

Methods


bindData(attribute, column, formatter)

Binds a Column data set to a specified aspect of this style. This creates
a single binding on this style instance. Check individual sub-styles to
see how many bindings they support.
Each binding is comprised of three key pieces: the style attribute being
bound, the Column data set that drives the style attribute, and a resolver
function that computes and returns an effective style attribute for any
given data value from the Column.

Parameters:
Name Type Description
attribute string

the name of the style attribute to be bound to a data Column. An
attribute is a visual aspect of the style, such as "Fill",
"Size" etc.

column object

A data column (typically an instance of OM.Column) that will
format the specified visual attribute of the style. If a String type
value is passed in, then it is assumed to be the name of
an property in the target VectorLayer's features.

formatter object

an instance of OM.style.Formatter; it
maps an individual item's value (such as sales volume) to a
particular visual style attribute value (such as a color).

Inherited From:

draw(feature, mapContext, options)

The actual logic for drawing a feature using a style is implemented in this method.
Must be overidden by sub-classes.

Parameters:
Name Type Description
feature OM.Feature

the feature to be applied with this style

mapContext OM.MapContext

the current map context

options Object

the rendering options, typically the graphics group

Inherited From:
Overrides:
Returns:
Type
undefined

enableNullFillPattern(imageSource)

Sets an image pattern to fill with in the marker whenever a fill is not
set in the marker style. If null is passed, then no fill pattern is to be
used.

Parameters:
Name Type Description
imageSource string | null

The fill pattern's URL


getBindables()

Returns a list of bindable style attributes.

Overrides:
Returns:

an array containing names of bindable attributes

Type
Array

getConfig()

Gets the config of style.

Inherited From:
Returns:

the config object


getStyleName()

Return the style name

Inherited From:
Returns:

the style name


hasBinding()

Checks if this style has associated data bindings.

Inherited From:
Returns:

true if there is one or more data bindings; false otherwise

Type
Boolean

isBindable(attr)

Checks whether a specified style attribute is bindable.

Parameters:
Name Type Description
attr String

the name of the attribute to be checked

Inherited From:
Returns:

true if the argument is bindable; false otherwise

Type
Boolean

isBound()

Checks whether a specified (bindable) attribute is already bound to some
Column data set.

Inherited From:

isFeatureBound(feature)

Checks whether the given feature is bound to any of the bindings in
this style.

Parameters:
Name Type Description
feature OM.Feature

the feature instance to be checked

Inherited From:
Returns:

returns true if the feature has associated values from
any of the style bindings' Column instances. Returns false if there
is no values associated with this feature, or there is no bindings
at all in this style.

Type
Boolean

resolveBinding(b, feature)

Resolves a specified binding for a given feature.
When a Style object has one or more of its visual attributes (such as Size
for a Marker style or Fill for a Color style) bound to an external data
column, then such visual attributes must be resolved for each and every feature
using the feature's associated data column value. The resolved visual
attribute values are then used to apply the style to that feature.

In other words, each time this method is called against a specific feature,
the following process always takes place:


  • the feature's unique id is obtained
  • the id is then used by the binding to find the corresponding data
    value from the associated Column instance
  • the data value is used to determine or resolve the visual attribute
    of this style such as Size or Fill color.
  • the visual attribute value is set on this Style instance for the
    duration of rendering the feature.

Parameters:
Name Type Description
b Object

the binding object

feature Object

the feature to be resolved with

Inherited From:
Returns:

the resolved style attribute

Type
Object

unbindAllData(attribute)

Un-binds all Column data sets currently bound to the specified style attribute.

Parameters:
Name Type Description
attribute String

the name of the style attribute

Inherited From:

unbindData(attribute)

Un-binds all Column data set for the given attribute.

Parameters:
Name Type Description
attribute String

name of the style attribute (such as 'Fill', 'Size'

Inherited From: