* @function FeatureThemeVector.prototype.geoTextToTF * @description 转换文本要素。 * @param {Geometry} geometry - 用户数据几何地理信息,这里必须是 GeoText。
(geometry)
| 585 | * @param {Geometry} geometry - 用户数据几何地理信息,这里必须是 GeoText。 |
| 586 | */ |
| 587 | geoTextToTF(geometry) { |
| 588 | //参考位置,参考中心为 |
| 589 | var location = this.location; |
| 590 | //geometry 像素坐标 |
| 591 | var localLX = this.getLocalXY(geometry); |
| 592 | |
| 593 | //赋 style |
| 594 | var style = new Object(); |
| 595 | style.r = 6; //防止漏设此参数,默认 6 像素 |
| 596 | style = CommonUtil.copyAttributesWithClip(style, this.style, ["x", "y", "text"]); |
| 597 | style.x = localLX[0] - location[0]; |
| 598 | style.y = localLX[1] - location[1]; |
| 599 | style.text = geometry.text; |
| 600 | |
| 601 | //创建图形 |
| 602 | var shape = new SmicText({ |
| 603 | style: style, |
| 604 | clickable: this.isClickAble, |
| 605 | hoverable: this.isHoverAble |
| 606 | }); |
| 607 | |
| 608 | //设置高亮样式 |
| 609 | if (this.highlightStyle) { |
| 610 | shape.highlightStyle = this.highlightStyle; |
| 611 | } |
| 612 | |
| 613 | //设置参考中心,指定图形位置 |
| 614 | shape.refOriginalPosition = location; |
| 615 | |
| 616 | //储存数据 id 属性,用于事件 |
| 617 | shape.refDataID = this.data.id; |
| 618 | |
| 619 | //储存数据 id 属性,用于事件-多图形同时高亮 |
| 620 | shape.isHoverByRefDataID = this.isMultiHover; |
| 621 | |
| 622 | //修改一些 shape 可选属性,通常不需要这么做 |
| 623 | if (this.shapeOptions) { |
| 624 | CommonUtil.copyAttributesWithClip(shape, this.shapeOptions); |
| 625 | } |
| 626 | |
| 627 | this.shapes.push(shape); |
| 628 | } |
| 629 | |
| 630 | |
| 631 | /** |
no test coverage detected