Class: TextBox

TextBox

Represents point type geometry for text boxes.
A TextBox is used to draw a box with text inside on a particular coordinate.

new TextBox(content, coordinates, width, height, optionsopt) [source]

var textbox = new maptalks.TextBox('This is a textbox',
    [0, 0], 200, 90,
    {
      'draggable' : true,
      'textStyle' : {
        'wrap' : true,
        'padding' : [12, 8],
        'verticalAlignment' : 'top',
        'horizontalAlignment' : 'right',
        'symbol' : {
          'textFaceName' : 'monospace',
          'textFill' : '#34495e',
          'textHaloFill' : '#fff',
          'textHaloRadius' : 4,
          'textSize' : 18,
          'textWeight' : 'bold'
        }
      },
      'boxSymbol': {
        // box's symbol
        'markerType' : 'square',
        'markerFill' : 'rgb(135,196,240)',
        'markerFillOpacity' : 0.9,
        'markerLineColor' : '#34495e',
        'markerLineWidth' : 1
      }
    });
Parameter Type Default Description
content String TextBox's text content
coordinates Coordinate coordinates
width Number width in pixel
height Number height in pixel
options opt Object null construct options defined in TextBox
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
    textStyle opt Boolean the default text style of text
    Properties
    Name Type Default Description
    wrap opt Boolean true whether to autowrap text in the textbox
    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
    boxSymbol opt Boolean null box symbol of textbox
    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.
    shadowBlur opt Number 0 level of the shadow around the geometry, see MDN's explanation
    shadowColor opt String black color of the shadow around the geometry, a CSS style color
    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

  • getWidth() [source]

  • Get textbox's width
    Returns:
    Number:
  • setWidth(width) [source]

  • Set new width to textbox
    Parameter Type Description
    width Number returns {TextBox} this

  • getHeight() [source]

  • Get textbox's height
    Returns:
    Number:
  • setHeight(height) [source]

  • Set new height to textbox
    Parameter Type Description
    height Number returns {TextBox} this

  • getBoxSymbol() [source]

  • Get textbox's boxSymbol
    Returns:
    Object: boxsymbol
  • setBoxSymbol(symbol) [source]

  • Set a new box symbol to textbox
    Parameter Type Description
    symbol Object returns {TextBox} this

  • getTextStyle() [source]

  • Get textbox's text style
    Returns:
    Object:
  • setTextStyle(style) [source]

  • Set a new text style to the textbox
    Parameter Type Description
    style Object new text style returns {TextBox} 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

  • (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: