@@ -2948,8 +2948,7 @@ export class WebMap extends Observable {
2948
2948
let featureType = parameters . featureType ,
2949
2949
style = parameters . style ,
2950
2950
themeSetting = parameters . themeSetting ;
2951
- let fieldName = themeSetting . themeField ,
2952
- colors = themeSetting . colors ;
2951
+ let fieldName = themeSetting . themeField ;
2953
2952
2954
2953
let names = [ ] ,
2955
2954
customSettings = themeSetting . customSettings ;
@@ -2968,37 +2967,57 @@ export class WebMap extends Observable {
2968
2967
}
2969
2968
}
2970
2969
2971
- //获取一定量的颜色
2972
- let curentColors = colors ;
2973
- curentColors = ColorsPickerUtil . getGradientColors ( curentColors , names . length ) ;
2974
2970
2975
2971
//生成styleGroup
2976
2972
let styleGroup = [ ] ;
2977
2973
names . forEach ( function ( name , index ) {
2978
2974
//兼容之前自定义是用key,现在因为数据支持编辑,需要用属性值。
2979
2975
let key = this . webMapVersion === "1.0" ? index : name ;
2980
- let color = curentColors [ key ] ;
2981
- if ( key in customSettings ) {
2982
- color = customSettings [ key ] ;
2983
- }
2984
-
2985
- if ( featureType === "LINE" ) {
2986
- style . strokeColor = color ;
2976
+ let custom = customSettings [ key ] ;
2977
+ if ( Util . isString ( custom ) ) {
2978
+ //兼容之前自定义只存储一个color
2979
+ custom = this . getCustomSetting ( style , custom , featureType ) ;
2980
+ customSettings [ key ] = custom ;
2981
+ }
2982
+
2983
+ // 转化成 ol 样式
2984
+ let olStyle , type = custom . type ;
2985
+ if ( type === 'SYMBOL_POINT' ) {
2986
+ olStyle = StyleUtils . getSymbolStyle ( custom ) ;
2987
+ } else if ( type === 'SVG_POINT' ) {
2988
+ olStyle = StyleUtils . getSVGStyle ( custom ) ;
2989
+ } else if ( type === 'IMAGE_POINT' ) {
2990
+ olStyle = StyleUtils . getImageStyle ( custom ) ;
2987
2991
} else {
2988
- style . fillColor = color ;
2992
+ olStyle = StyleUtils . toOpenLayersStyle ( custom , featureType ) ;
2989
2993
}
2990
- // 转化成 ol 样式
2991
- let olStyle = StyleUtils . toOpenLayersStyle ( style , featureType ) ;
2992
2994
styleGroup . push ( {
2993
2995
olStyle : olStyle ,
2994
- color : color ,
2996
+ style : customSettings [ key ] ,
2995
2997
value : name
2996
2998
} ) ;
2997
2999
} , this ) ;
2998
3000
2999
3001
return styleGroup ;
3000
3002
}
3001
3003
3004
+ /**
3005
+ * 获取单值专题图自定义样式对象
3006
+ * @param {* } style 图层上的样式
3007
+ * @param {* } color 单值对应的颜色
3008
+ * @param {* } featureType 要素类型
3009
+ */
3010
+ getCustomSetting ( style , color , featureType ) {
3011
+ let newProps = { } ;
3012
+ if ( featureType === "LINE" ) {
3013
+ newProps . strokeColor = color ;
3014
+ } else {
3015
+ newProps . fillColor = color ;
3016
+ }
3017
+ let customSetting = Object . assign ( style , newProps )
3018
+ return customSetting ;
3019
+ }
3020
+
3002
3021
/**
3003
3022
* @private
3004
3023
* @function ol.supermap.WebMap.prototype.createRangeLayer
0 commit comments