* @function Label.prototype.getStyleByData * @description 根据用户数据(feature)设置专题要素的风格。 * @param {FeatureVector} feat - 矢量要素对象。 * @returns {Array. } 专题要素的风格。
(feat)
| 325 | * @returns {Array.<ThemeStyle>} 专题要素的风格。 |
| 326 | */ |
| 327 | getStyleByData(feat) { |
| 328 | var feature = feat; |
| 329 | feature.style = CommonUtil.copyAttributes(feature.style, this.defaultStyle); |
| 330 | //将style赋给标签 |
| 331 | if (this.style && this.style.fontSize && parseFloat(this.style.fontSize) < 12) { |
| 332 | this.style.fontSize = "12px"; |
| 333 | } |
| 334 | feature.style = CommonUtil.copyAttributes(feature.style, this.style); |
| 335 | |
| 336 | if (this.themeField && this.styleGroups && feature.attributes) { |
| 337 | var Sf = this.themeField; |
| 338 | var attributes = feature.attributes; |
| 339 | var groups = this.styleGroups; |
| 340 | var isSfInAttrs = false; //指定的 groupField 是否是geotext的属性字段之一 |
| 341 | var attr = null; //属性值 |
| 342 | |
| 343 | for (var property in attributes) { |
| 344 | if (Sf === property) { |
| 345 | isSfInAttrs = true; |
| 346 | attr = attributes[property]; |
| 347 | break; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | //判断属性值是否属于styleGroups的某一个范围,以便对标签分组 |
| 352 | if (isSfInAttrs) { |
| 353 | for (var i = 0, len = groups.length; i < len; i++) { |
| 354 | if ((attr >= groups[i].start) && (attr < groups[i].end)) { |
| 355 | var sty1 = groups[i].style; |
| 356 | if (sty1 && sty1.fontSize && parseFloat(sty1.fontSize) < 12) { |
| 357 | sty1.fontSize = "12px"; |
| 358 | } |
| 359 | feature.style = CommonUtil.copyAttributes(feature.style, sty1); |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | feature.style.label = feature.attributes[this.themeField] |
| 364 | } |
| 365 | |
| 366 | |
| 367 | return feature.style; |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * @function Label.prototype.setLabelsStyle |
no outgoing calls
no test coverage detected