MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _createUniqueLayer

Method _createUniqueLayer

src/common/mapping/WebMapV2.js:1672–2144  ·  view source on GitHub ↗
(layerInfo, features)

Source from the content-addressed store, hash-verified

1670 }
1671
1672 async _createUniqueLayer(layerInfo, features) {
1673 const symbolConvertFunctionFactory = {
1674 unicode: ({ unicode }) => {
1675 return String.fromCharCode(parseInt(unicode.replace(/^&#x/, ''), 16));
1676 },
1677 fontSize: ({ fontSize }) => {
1678 if (fontSize) {
1679 return parseFloat(fontSize);
1680 }
1681 return 12;
1682 },
1683 rotation: ({ rotation }) => {
1684 return ((rotation || 0) * 180) / Math.PI;
1685 },
1686 fillColor: ({ fillColor, fillOpacity }) => {
1687 return ColorsPickerUtil.getColorWithOpacity(fillColor, fillOpacity);
1688 },
1689 strokeColor: ({ strokeColor, strokeOpacity }) => {
1690 return ColorsPickerUtil.getColorWithOpacity(strokeColor || 'rgba(0,0,0,0)', strokeOpacity);
1691 },
1692 strokeWidth: ({ strokeWidth }) => {
1693 return strokeWidth || 0;
1694 },
1695 offsetX: ({ offsetX, offsetY }) => {
1696 return [offsetX / 2 || 0, offsetY / 2 || 0];
1697 }
1698 };
1699 const defaultValueFactory = {
1700 unicode: '',
1701 fontSize: 12,
1702 rotation: 0,
1703 strokeColor: 'rgba(0,0,0,0)',
1704 fillColor: 'rgba(0,0,0,0)',
1705 strokeWidth: 0,
1706 offsetX: [0, 0]
1707 };
1708 const styleGroup = this.getUniqueStyleGroup(layerInfo, features);
1709 features = this.getFilterFeatures(layerInfo.filterCondition, features);
1710 const { layerID, minzoom, maxzoom, style } = layerInfo;
1711 const themeField = styleGroup[0].themeField;
1712 const type = layerInfo.featureType;
1713
1714 const defultLayerStyle = layerInfo.style;
1715 // 样式expression池 样式key值为webmap的样式key值
1716 const expressionMap = {};
1717 // 自定义单值值对应的样式
1718 const customStyleMap = {};
1719 styleGroup.forEach((style) => {
1720 customStyleMap[style.value] = style;
1721 });
1722 // 遍历要素,判断该要素是不是在自定义单值中,若是在对应样式match expression中增加改要素的索引
1723 features.forEach(({ properties }) => {
1724 const customStyle = customStyleMap[properties[themeField]];
1725 if (customStyle) {
1726 const itemStyle = customStyle.style;
1727 for (const key in itemStyle) {
1728 if (Object.prototype.hasOwnProperty.call(itemStyle, key)) {
1729 const itemStyleElement = itemStyle[key];

Callers 1

_initOverlayLayerMethod · 0.95

Calls 15

_initLegendConfigInfoMethod · 0.95
_addLayerMethod · 0.95
_createSymbolLayerMethod · 0.95
_createGraphicLayerMethod · 0.95
_addLayerSucceededMethod · 0.95
getColorWithOpacityMethod · 0.80
getFilterFeaturesMethod · 0.80
forEachMethod · 0.80
pushMethod · 0.80
addSourceMethod · 0.80
fnFunction · 0.50
getUniqueStyleGroupMethod · 0.45

Tested by

no test coverage detected