* @private * @function WebMap.prototype.setFeatureStyle * @description 设置feature样式 * @param {Object} layer - 图层对象 * @param {string} directionField - 方向字段 * @param {string} styleType - 样式的类型
(layer, directionField, styleType)
| 4008 | * @param {string} styleType - 样式的类型 |
| 4009 | */ |
| 4010 | setFeatureStyle(layer, directionField, styleType) { |
| 4011 | let layerStyle = layer.get('styleOL'); |
| 4012 | layer.setStyle((feature) => { |
| 4013 | //有转向字段 |
| 4014 | let value, image; |
| 4015 | if (directionField !== undefined && directionField !== '未设置' && directionField !== 'None') { |
| 4016 | value = feature.get('attributes')[directionField]; |
| 4017 | } else { |
| 4018 | value = 0; |
| 4019 | } |
| 4020 | if (value > 360 || value < 0) { |
| 4021 | return null; |
| 4022 | } |
| 4023 | if (styleType === 'SYMBOL_POINT') { |
| 4024 | image = layerStyle.getText(); |
| 4025 | } else { |
| 4026 | image = layerStyle.getImage(); |
| 4027 | } |
| 4028 | //默认用户使用的是角度,换算成弧度 |
| 4029 | let rotate = (Math.PI * value) / 180; |
| 4030 | image && image.setRotation(rotate); |
| 4031 | return layerStyle; |
| 4032 | }); |
| 4033 | } |
| 4034 | |
| 4035 | /** |
| 4036 | * @private |
no test coverage detected