Summary
Methods:
clone |
克隆一个字体图标符号。 |
getAnchor |
获取锚点的位置。 |
getFileUrl |
获取自定义字体图标的文件地址 |
getFillColor |
获取填充色 |
getFontFamily |
获取字体图标的字体样式 |
getFontSize |
获取字体图标的大小。 |
getOffset |
获取符号的偏移量。 |
getOpacity |
获取符号的透明度。 |
getOutlineColor |
获取描边颜色 |
getOutlineWidth |
获取描边的宽度 |
getRotateWithView |
获得符号是否跟着地图旋转。 |
getRotation |
获取符号的旋转角度。单位是角度制。 |
getUnicode |
获取unicode |
setAnchor |
设置锚点位置。 |
setFileUrl |
设置字体图标文件的路径。 |
setFillColor |
设置填充色 |
setFontSize |
设置字体图标的大小。 |
setOffset |
设置符号的偏移量。 |
setOpacity |
设置透明度。 |
setOutlineColor |
设置描边色 |
setOutlineWidth |
设置描边宽 |
setRotation |
设置旋转角度。单位是角度制。 |
setUnicode |
设置unicode编码 |
Constructor
new IconFont(options)
Iconfont的构造函数。 options参数中:fileUrl、unicode是必需的。其他属性是可选项。
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
|
Throws:
当字体图标参数填充颜色fillColor或者描边颜色outlineColor不是Color类型时,抛出异常:'parameter "fillColor" and "outlineColor" must be instance of Color'。
Example
let iconFont = new hmap.style.IconFont({
"unicode":"",//unicode编码
"fileUrl":"./mapicon.ttf",//ttf文件的加载路径
"opacity":1.0,//整个iconfont图标的透明度
"anchor":[0,0],//偏移量,单位分数
"fontSize":16,//大小
"fillColor":new hmap.style.Color(255,255,255,0),//填充色
"outlineColor":new hmap.style.Color(0,0,0,1),//外边框颜色
"outlineWidth":1,//外边框宽度
"rotation":0
});
Methods
-
clone() → {module:style~IconFont}
-
克隆一个字体图标符号。
Returns:
module:style~IconFontExample
let newIconFont = iconFont.clone();
-
getAnchor() → {Array}
-
获取锚点的位置。
Returns:
Array -锚点的位置
Example
let anchor = iconFont.getAnchor();
-
getFileUrl() → {String}
-
获取自定义字体图标的文件地址
Returns:
StringExample
let fileUrl = iconFont.getFileUrl();
-
getFillColor() → {module:style~Color}
-
获取填充色
Returns:
module:style~ColorExample
let fillColor = iconFont.getFillColor();
-
getFontFamily() → {String}
-
获取字体图标的字体样式
Returns:
String -字体样式
Example
let fontFamily = iconFont.getFontFamily();
-
getFontSize() → {Number}
-
获取字体图标的大小。
Returns:
NumberExample
let size = iconFont.getFontSize();
-
getOffset() → {module:basetype~Offset}
-
获取符号的偏移量。
-
getOpacity() → {Number}
-
获取符号的透明度。
Returns:
Number -透明度
-
getOutlineColor() → {module:style~Color}
-
获取描边颜色
Returns:
module:style~ColorExample
let outLineColor = iconFont.getOutlineColor();
-
getOutlineWidth() → {Number}
-
获取描边的宽度
Returns:
NumberExample
let outLineWidth = iconFont.getOutlineWidth();
-
getRotateWithView() → {Boolean}
-
获得符号是否跟着地图旋转。
Returns:
Boolean -如果旋转返回true;如果不旋转,返回false。
Example
let iconSymbol = new hmap.style.Icon(); let result = iconSymbol.getRotateWithView();//result=false
-
getRotation() → {Number}
-
获取符号的旋转角度。单位是角度制。
Returns:
Number -旋转角度
-
getUnicode() → {String}
-
获取unicode
Returns:
StringExample
let unicode = iconFont.getUnicode();
-
setAnchor(anchor)
-
设置锚点位置。
Parameters:
Name Type Description anchor
Array Example
iconFont.setAnchor([0.1,0.1]);
-
setFileUrl(fileUrl)
-
设置字体图标文件的路径。
Parameters:
Name Type Description fileUrl
String 字体图标文件的路径
Example
iconFont.setFileUrl("./mapicon.ttf");
-
setFillColor(fillColor)
-
设置填充色
Parameters:
Name Type Description fillColor
module:style~Color 填充色
Throws:
当参数不是Color类型时,抛出异常:'parameter "fillColor" must be instance of Color'。
Example
let fillColor = new hmap.style.Color(255,2,2,1); iconFont.setFillColor(fillColor);
-
setFontSize(fontSize)
-
设置字体图标的大小。
Parameters:
Name Type Description fontSize
Number Example
iconFont.setFontSize(20);
-
setOffset(offset)
-
设置符号的偏移量。
Parameters:
Name Type Description offset
module:basetype~Offset 偏移量
Throws:
当参数不是Offset对象时,抛出异常:"The parameter must be a Offset"。
-
setOpacity(opacity)
-
设置透明度。
Parameters:
Name Type Description opacity
Number 透明度,透明度的范围是[0,1]。
Throws:
当参数的值不在0到1之间时,抛出异常:“The extent of the parameter 'opacity' is [0,1]”。
-
setOutlineColor(outlineColor)
-
设置描边色
Parameters:
Name Type Description outlineColor
module:style~Color 描边色
Throws:
当参数不是Color类型时,抛出异常:'parameter "outlineColor" must be instance of Color'。
Example
let color = new hmap.style.Color(2,255,2,1); iconFont.setOutlineColor(color);
-
setOutlineWidth(outlineWidth)
-
设置描边宽
Parameters:
Name Type Description outlineWidth
Number 描边宽
Example
iconFont.setOutlineWidth(2);
-
setRotation(rotation)
-
设置旋转角度。单位是角度制。
Parameters:
Name Type Description rotation
Number 旋转角度
-
setUnicode(unicode)
-
设置unicode编码
Parameters:
Name Type Description unicode
String Example
iconFont.setUnicode("");