MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / getStyleByData

Method getStyleByData

src/mapboxgl/overlay/UniqueThemeLayer.js:76–108  ·  view source on GitHub ↗

* @private * @function UniqueThemeLayer.prototype.getStyleByData * @description 通过数据获取 style。 * @param {Object} fea - 要素数据。

(fea)

Source from the content-addressed store, hash-verified

74 * @param {Object} fea - 要素数据。
75 */
76 getStyleByData(fea) {
77 var style = {};
78 var feature = fea;
79 style = CommonUtil.copyAttributesWithClip(style, this.style);
80 if (this.themeField && this.styleGroups && this.styleGroups.length > 0 && feature.attributes) {
81 var tf = this.themeField;
82 var Attrs = feature.attributes;
83 var Gro = this.styleGroups;
84 var isSfInAttrs = false; //指定的 themeField 是否是 feature 的属性字段之一
85 var attr = null; //属性值
86 for (var property in Attrs) {
87 if (tf === property) {
88 isSfInAttrs = true;
89 attr = Attrs[property];
90 break;
91 }
92 }
93 //判断属性值是否属于styleGroups的某一个范围,以便对获取分组 style
94 if (isSfInAttrs) {
95 for (var i = 0, len = Gro.length; i < len; i++) {
96 if ((attr).toString() === ( Gro[i].value).toString()) {
97 //feature.style = CommonUtil.copyAttributes(feature.style, this.defaultStyle);
98 var sty1 = Gro[i].style;
99 style = CommonUtil.copyAttributesWithClip(style, sty1);
100 }
101 }
102 }
103 }
104 if (feature.style && this.isAllowFeatureStyle === true) {
105 style = CommonUtil.copyAttributesWithClip(feature.style);
106 }
107 return style;
108 }
109
110}

Callers 1

createThematicFeatureMethod · 0.95

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected