<< Click to Display Table of Contents >>

SuperGIS Server JavaScript API

 

new sg.symbols.TextSymbol(text, font, color)

 

 

Description

建立一個(具有參數的)TextSymbol 物件。

 

Position

Symbol.js

 

 

Parameters

 

Parameter

Type

Description

text_or_json

String

(optional)文字內容的定義。

font

sg.Font

(optional)字體定義。

color

sg.Font

(optional)文字的顏色。

 

 

Constants

 

Constants

Description

ALIGN_END

向右對齊。

ALIGN_MIDDLE

靠中對齊。

ALIGN_START

向左對齊。

DECORATION_LINETHROUGH

刪除線。

DECORATION_NONE

無字體裝飾。

DECORATION_OVERLINE

上行線。

DECORATION_UNDERLINE

底線。

 

 

Properties

 

Properties

Type

Description

align

String

對齊方式定義。

angle

Number

旋轉角度定義。

color

sg.Color

文字的顏色。

font

sg.Font

字體定義。

kerning

String

文字間是否相隔間距的定義。

rotated

Boolean

各文字字串是否旋轉的定義。

text

String

文字內容的定義。

type

String

符號的類型。

xoffset

Number

x 方向偏移量的定義。

yoffset

Number

y 方向偏移量的定義。

 

 

Methods

 

Methods

Type

Description

setAlign(align)

String

設定文字對齊方式。

(參考Constants列舉定義)

Name

Type

Description

align

String

對齊方式

setAngle(angle)

Number

設定文字旋轉角度。

Name

Type

Description

angle

Number

旋轉角度

setColor(color)

sg.Color

設定文字顏色。

Name

Type

Description

color

sg.Color

顏色

setFont(font)

sg.Font

設定文字字體。

Name

Type

Description

font

sg.Font

文字字體。

setKerning(kerning)

String

設定文字間相隔間距。

Name

Type

Description

kerning

String


setOffset(x,y)

Number

設定x 與y 方向偏移量。

Name

Type

Description

x

Number

x方向偏移量

y

Number

y方向偏移量

setRotated(rotated)

Boolean

設定各文字字串是否旋轉。

Name

Type

Description

rotated

Boolean

True: 旋轉

False: 不旋轉

setText(text)

String

設定文字內容。

Name

Type

Description

text

String

文字內容

 

Example

 

<script type="text/javascript" src="scripts/Symbol.js"></script>

// example 1

var color = new sg.Color(255, 0, 0, 1);

var font =new sg.symbols.Font(24,sg.symbols.Font.STYLE_NORMAL,sg.symbols.Font.VARIANT_NORMAL,sg.symbols.Font.WEIGHT_NORMAL,"arial");

 

var TextSymbol = new sg.symbols.TextSymbol(“abcd”, font, color);

 

// example 2

var color = new sg.Color(255, 0, 0, 1);

var font =new sg.symbols.Font(24,sg.symbols.Font.STYLE_NORMAL,sg.symbols.Font.VARIANT_NORMAL,sg.symbols.Font.WEIGHT_NORMAL,"arial");

 

var TextSymbol = new sg.symbols.TextSymbol();

TextSymbol.setColor(color);

TextSymbol.setFont(font);

TextSymbol.setText(“abcd”);

 

 

 

See live example

 


©2015 Supergeo Technologies Inc.