Class: Label

Label

Represents point type geometry for text labels.
A label is used to draw text (with a box background if specified) on a particular coordinate.

new Label(content, coordinates, optionsopt) [source]

var label = new maptalks.Label('label with a box',
    [0, 0],
    {
      'draggable' : true,
      'boxStyle' : {
        'padding' : [12, 8],
        'verticalAlignment' : 'top',
        'horizontalAlignment' : 'right',
        'minWidth' : 300,
        'minHeight' : 200,
        'symbol' : {
          'markerType' : 'square',
          'markerFill' : 'rgb(135,196,240)',
          'markerFillOpacity' : 0.9,
          'markerLineColor' : '#34495e',
          'markerLineWidth' : 1
        }
      },
      'textSymbol': {
        'textFaceName' : 'monospace',
        'textFill' : '#34495e',
        'textHaloFill' : '#fff',
        'textHaloRadius' : 4,
        'textSize' : 18,
        'textWeight' : 'bold',
        'textVerticalAlignment' : 'top'
      }
    });
Parameter Type Default Description
content String Label's text content
coordinates Coordinate coordinates
options opt Object null construct options defined in Label
Extends:
Mixes From:
Fires:

Members

  • (constant) options

  • Properties:
    Name Type Default Description
    options opt Object null textbox's options, also including options of Marker
    Properties
    Name Type Default Description
    boxStyle opt Boolean null the default box style of text
    Properties
    Name Type Default Description
    padding opt Boolean [12, 8] text padding in the box
    verticalAlignment opt Boolean middle text's vertical alignment
    horizontalAlignment opt Boolean true text's horizontal alignment
    minWidth opt Number 0 label box's minWidth
    minHeight opt Number 0 label box's minHeight
    textSymbol opt Boolean null text symbol of label
    id opt Boolean null id of the geometry
    visible opt Boolean true whether the geometry is visible.
    editable opt Boolean true whether the geometry can be edited.
    cursor opt String null cursor style when mouseover the geometry, same as the definition in CSS.
    measure opt String EPSG:4326 the measure code for the geometry, defines measureGeometry how it can be measured.
    draggable opt Boolean false whether the geometry can be dragged.
    dragShadow opt Boolean false if true, during geometry dragging, a shadow will be dragged before geometry was moved.
    dragOnAxis opt Boolean null if set, geometry can only be dragged along the specified axis, possible values: x, y
    Source:

    Methods

  • getBoxStyle() [source]

  • Get label's box style
    Returns:
    Object:
  • setBoxStyle(style) [source]

  • Set a new box style to the label
    Parameter Type Description
    style Object
    Returns:
    Label: this
  • getTextSymbol() [source]

  • Get label's text symbol
    Returns:
    Object:
  • setTextSymbol(symbol) [source]

  • Set a new text symbol to the label
    Parameter Type Description
    symbol Object
    Returns:
    Label: this
  • (mixin) startEditText() [source]

  • Start to edit the text, editing will be ended automatically whenever map is clicked.
    Mixes From:
    Fires:
    Returns:
    TextMarker: this
  • (mixin) endEditText() [source]

  • End text edit.
    Mixes From:
    Fires:
    Returns:
    TextMarker: this
  • (mixin) isEditingText() [source]

  • Whether the text is being edited.
    Mixes From:
    Returns:
    Boolean:
  • (mixin) getTextEditor() [source]

  • Get the text editor which is an ui.UIMarker
    Mixes From:
    Returns:
    ui.UIMarker: text editor
  • (inherited) getContent() [source]

  • Get text content of the label
    Inherited From:
    Returns:
    String:
  • (inherited) setContent() [source]

  • Set a new text content to the label
    Inherited From:
    Fires:
    Returns:
    Label: this

    Events

  • contentchange [source]

  • an event when changing label's text content
    Properties:
    Name Type Description
    type String contentchange
    target Label label fires the event
    old String old content
    new String new content
    Source:

  • (inherited) edittextstart [source]

  • edittextstart when starting to edit text content
    Inherited From:
    Properties:
    Name Type Description
    type String edittextstart
    target TextMarker fires the event
    Inherited From:
    Source:

  • (inherited) edittextend [source]

  • edittextend when ended editing text content
    Inherited From:
    Properties:
    Name Type Description
    type String edittextend
    target TextMarker textMarker fires the event
    Inherited From:
    Source: