(layerInfo, features)
| 951 | } |
| 952 | |
| 953 | _createVectorLayer(layerInfo, features) { |
| 954 | const type = layerInfo.featureType; |
| 955 | const { layerID, minzoom, maxzoom, style, visible, parentLayerId = layerID } = layerInfo; |
| 956 | const layerSource = this.map.getSource(layerID); |
| 957 | const sourceData = { |
| 958 | type: 'FeatureCollection', |
| 959 | features: features |
| 960 | }; |
| 961 | if (!layerSource) { |
| 962 | const source = { |
| 963 | type: 'geojson', |
| 964 | data: sourceData |
| 965 | }; |
| 966 | this.map.addSource(layerID, source); |
| 967 | } else { |
| 968 | layerSource.setData(sourceData); |
| 969 | } |
| 970 | const styleArr = Array.isArray(style) ? style : [style]; |
| 971 | if (styleArr.length === 2) { |
| 972 | // 道路 |
| 973 | if (styleArr[0].lineDash === 'solid' && styleArr[1].lineDash === 'solid') { |
| 974 | styleArr[0].strokeWidth = styleArr[1].strokeWidth; |
| 975 | styleArr[1].strokeWidth = styleArr[1].strokeWidth - 2; |
| 976 | } |
| 977 | // 铁路 |
| 978 | if (styleArr[0].lineDash === 'solid' && styleArr[1].lineDash === 'dash') { |
| 979 | styleArr[0].strokeWidth = styleArr[1].strokeWidth; |
| 980 | styleArr[1].strokeWidth = styleArr[1].strokeWidth * 0.5; |
| 981 | styleArr[1].lineDash = 'dashrailway'; |
| 982 | } |
| 983 | } |
| 984 | styleArr.forEach((element, index) => { |
| 985 | const layerStyle = { |
| 986 | style: this._transformStyleToMapBoxGl(element, type), |
| 987 | layout: { |
| 988 | visibility: visible |
| 989 | } |
| 990 | }; |
| 991 | const newLayerID = index === 0 ? layerID : `${layerID}-additional-${index}`; |
| 992 | this._addOverlayToMap({ |
| 993 | type, |
| 994 | source: layerID, |
| 995 | layerID: newLayerID, |
| 996 | parentLayerId, |
| 997 | layerStyle, |
| 998 | minzoom, |
| 999 | maxzoom |
| 1000 | }); |
| 1001 | }); |
| 1002 | // 如果面有边框 |
| 1003 | type === 'POLYGON' && |
| 1004 | style.strokeColor && |
| 1005 | this._addStrokeLineForPoly({ |
| 1006 | style, |
| 1007 | source: layerID, |
| 1008 | layerID: layerID + '-strokeLine', |
| 1009 | parentLayerId: layerID, |
| 1010 | visible, |
no test coverage detected