1- import mapboxgl from " @mapgis/mapbox-gl" ;
2- import { Zondy } from " ../../service/common/Base" ;
3- import { copyAttributesWithClip } from " ../../service/common/Util" ;
4- import { GeoFeatureThemeLayer } from " ./GeoFeatureThemeLayer" ;
5- import { ThemeVector } from " ../../common/overlay/ThemeVector" ;
6- import { ShapeFactory } from " ../../common/overlay/feature/ShapeFactory" ;
1+ import mapboxgl from ' @mapgis/mapbox-gl' ;
2+ import { Zondy } from ' ../../service/common/Base' ;
3+ import { copyAttributesWithClip } from ' ../../service/common/Util' ;
4+ import { GeoFeatureThemeLayer } from ' ./GeoFeatureThemeLayer' ;
5+ import { ThemeVector } from ' ../../common/overlay/ThemeVector' ;
6+ import { ShapeFactory } from ' ../../common/overlay/feature/ShapeFactory' ;
77
88/**
99 * @class Zondy.Map.randomThemeLayer
@@ -22,74 +22,70 @@ import { ShapeFactory } from "../../common/overlay/feature/ShapeFactory";
2222 * @extends {Zondy.Map.GeoFeatureThemeLayer }
2323 */
2424class RandomThemeLayer extends GeoFeatureThemeLayer {
25- constructor ( name , options ) {
26- super ( name , options ) ;
27- this . style = options . style ;
28- this . isHoverAble = options . isHoverAble ;
29- this . highlightStyle = options . highlightStyle ;
30- this . themeField = options . themeField ;
31- this . styleGroups = options . styleGroups ;
32- }
25+ constructor ( name , options ) {
26+ super ( name , options ) ;
27+ this . style = options . style ;
28+ this . isHoverAble = options . isHoverAble ;
29+ this . highlightStyle = options . highlightStyle ;
30+ this . themeField = options . themeField ;
31+ this . styleGroups = options . styleGroups ;
32+ }
3333
34- /**
35- * @function Zondy.Map.randomThemeLayer.prototype.getColor
36- * @description 获取随机颜色。
37- */
38- getColor ( ) {
39- var colorValue = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f" ;
40- var colorArray = colorValue . split ( "," ) ;
41- var color = "#" ; //定义一个存放十六进制颜色值的字符串变量,先将#存放进去
42- for ( var i = 0 ; i < 6 ; i ++ ) {
43- color += colorArray [ Math . floor ( Math . random ( ) * 16 ) ] ;
34+ /**
35+ * @function Zondy.Map.randomThemeLayer.prototype.getColor
36+ * @description 获取随机颜色。
37+ */
38+ getColor ( ) {
39+ var colorValue = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f' ;
40+ var colorArray = colorValue . split ( ',' ) ;
41+ var color = '#' ; //定义一个存放十六进制颜色值的字符串变量,先将#存放进去
42+ for ( var i = 0 ; i < 6 ; i ++ ) {
43+ color += colorArray [ Math . floor ( Math . random ( ) * 16 ) ] ;
44+ }
45+ return color ;
4446 }
45- return color ;
46- }
4747
48- /**
49- * @function Zondy.Map.randomThemeLayer.prototype.createThematicFeature
50- * @description 创建专题图要素。
51- * @param {Object } feature - 要创建的专题图形要素。
52- */
53- createThematicFeature ( feature ) {
54- //赋 style
55- var style = this . getStyleByData ( feature ) ;
56- //创建专题要素时的可选参数
57- var options = { } ;
58- options . nodesClipPixel = this . nodesClipPixel ;
59- options . isHoverAble = this . isHoverAble ;
60- options . isMultiHover = this . isMultiHover ;
61- options . isClickAble = this . isClickAble ;
62- options . highlightStyle = ShapeFactory . transformStyle ( this . highlightStyle ) ;
48+ /**
49+ * @function Zondy.Map.randomThemeLayer.prototype.createThematicFeature
50+ * @description 创建专题图要素。
51+ * @param {Object } feature - 要创建的专题图形要素。
52+ */
53+ createThematicFeature ( feature ) {
54+ //赋 style
55+ var style = this . getStyleByData ( feature ) ;
56+ //创建专题要素时的可选参数
57+ var options = { } ;
58+ options . nodesClipPixel = this . nodesClipPixel ;
59+ options . isHoverAble = this . isHoverAble ;
60+ options . isMultiHover = this . isMultiHover ;
61+ options . isClickAble = this . isClickAble ;
62+ options . highlightStyle = ShapeFactory . transformStyle ( this . highlightStyle ) ;
6363
64- //将数据转为专题要素(Vector)
65- var thematicFeature = new ThemeVector (
66- feature ,
67- this ,
68- ShapeFactory . transformStyle ( style ) ,
69- options
70- ) ;
64+ //将数据转为专题要素(Vector)
65+ var thematicFeature = new ThemeVector ( feature , this , ShapeFactory . transformStyle ( style ) , options ) ;
7166
72- //直接添加图形到渲染器
73- for ( var m = 0 ; m < thematicFeature . shapes . length ; m ++ ) {
74- this . renderer . addShape ( thematicFeature . shapes [ m ] ) ;
67+ //直接添加图形到渲染器
68+ for ( var m = 0 ; m < thematicFeature . shapes . length ; m ++ ) {
69+ this . renderer . addShape ( thematicFeature . shapes [ m ] ) ;
70+ }
71+ return thematicFeature ;
7572 }
76- return thematicFeature ;
77- }
7873
79- /**
80- * @private
81- * @function Zondy.Map.randomThemeLayer.prototype.getStyleByData
82- * @description 获取 style。
83- */
84- getStyleByData ( ) {
85- var me = this ;
86- var style = copyAttributesWithClip ( { } , me . style ) ;
87- style . fillColor = me . getColor ( ) ;
88- return style ;
89- }
74+ /**
75+ * @private
76+ * @function Zondy.Map.randomThemeLayer.prototype.getStyleByData
77+ * @description 获取 style。
78+ */
79+ getStyleByData ( ) {
80+ var me = this ;
81+ var style = copyAttributesWithClip ( { } , me . style ) ;
82+ style . fillColor = me . getColor ( ) ;
83+ return style ;
84+ }
9085}
9186
92- export var randomThemeLayer = function ( name , options ) {
93- return new RandomThemeLayer ( name , options ) ;
87+ export { RandomThemeLayer } ;
88+ export var randomThemeLayer = function ( name , options ) {
89+ return new RandomThemeLayer ( name , options ) ;
9490} ;
9591Zondy . Map . randomThemeLayer = randomThemeLayer ;
0 commit comments