@@ -4,6 +4,7 @@ import {tiledMapLayer} from '../../../src/leaflet/mapping/TiledMapLayer';
44import { ThemeStyle } from '../../../src/common/style/ThemeStyle' ;
55import { Bounds } from '../../../src/common/commonTypes/Bounds' ;
66import '../../resources/themeLabelData' ;
7+ import { LevelRenderer } from "@supermap/iclient-common" ;
78
89var url = GlobeParameter . China4326URL ;
910var themeLayer ;
@@ -17,6 +18,7 @@ var addThemeFeatures = () => {
1718 var text = themeData [ i ] . aqi ;
1819 feat = themeFeature ( [ lat , lng , text ] , themeData [ i ] ) ;
1920 labelFeatures . push ( feat ) ;
21+
2022 }
2123 themeLayer . addFeatures ( labelFeatures ) ;
2224}
@@ -141,6 +143,39 @@ describe('leaflet_LabelThemeLayer', () => {
141143 expect ( themeLayer . styleGroups . length ) . toEqual ( 6 ) ;
142144 } ) ;
143145
146+ //清除当前图层的所有矢量要素
147+ it ( 'removeAllFeatures' , ( ) => {
148+ themeLayer . removeAllFeatures ( ) ;
149+ expect ( themeLayer . labelFeatures . length ) . toEqual ( 0 ) ;
150+ themeLayer . clearCache ( ) ;
151+ expect ( themeLayer . cache ) . toEqual ( { } ) ;
152+ expect ( themeLayer . cacheFields . length ) . toEqual ( 0 ) ;
153+ //renderer.clear(); not write
154+ themeLayer . on ( "featuresremoved" , function ( e ) {
155+ expect ( e . features . length ) . toEqual ( 0 ) ;
156+ expect ( e . success ) . toBeTruthy ( ) ;
157+ } ) ;
158+ map . zoomIn ( 6 ) ;
159+ //模拟地图缩放场景
160+ map . on ( "zoomend" , function ( ) {
161+ expect ( themeLayer . labelFeatures . length ) . toEqual ( 0 ) ;
162+ themeLayer . clearCache ( ) ;
163+ expect ( themeLayer . cache ) . toEqual ( { } ) ;
164+ expect ( themeLayer . cacheFields . length ) . toEqual ( 0 ) ;
165+ } ) ;
166+ } ) ;
167+
168+ it ( 'setOpacity' , ( ) => {
169+ themeLayer . setOpacity ( 0 ) ;
170+ expect ( themeLayer . options . opacity ) . toEqual ( 0 ) ;
171+ themeLayer . _updateOpacity ( ) ;
172+
173+ map . on ( "changelayer" , function ( e ) {
174+ expect ( e . layer ) . toBe ( themeLayer ) ;
175+ expect ( e . property ) . toEqual ( 0 ) ;
176+ } ) ;
177+ } ) ;
178+
144179 //获取经(压盖)处理后将要绘制在图层上的标签要素,原参数数据往右上方避让
145180 it ( 'getDrawnLabels' , ( ) => {
146181 var labelFeatures = themeLayer . labelFeatures ;
0 commit comments