@@ -4,6 +4,7 @@ import {tiledMapLayer} from '../../../src/leaflet/mapping/TiledMapLayer';
4
4
import { ThemeStyle } from '../../../src/common/style/ThemeStyle' ;
5
5
import { Bounds } from '../../../src/common/commonTypes/Bounds' ;
6
6
import '../../resources/themeLabelData' ;
7
+ import { LevelRenderer } from "@supermap/iclient-common" ;
7
8
8
9
var url = GlobeParameter . China4326URL ;
9
10
var themeLayer ;
@@ -17,6 +18,7 @@ var addThemeFeatures = () => {
17
18
var text = themeData [ i ] . aqi ;
18
19
feat = themeFeature ( [ lat , lng , text ] , themeData [ i ] ) ;
19
20
labelFeatures . push ( feat ) ;
21
+
20
22
}
21
23
themeLayer . addFeatures ( labelFeatures ) ;
22
24
}
@@ -141,6 +143,39 @@ describe('leaflet_LabelThemeLayer', () => {
141
143
expect ( themeLayer . styleGroups . length ) . toEqual ( 6 ) ;
142
144
} ) ;
143
145
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
+
144
179
//获取经(压盖)处理后将要绘制在图层上的标签要素,原参数数据往右上方避让
145
180
it ( 'getDrawnLabels' , ( ) => {
146
181
var labelFeatures = themeLayer . labelFeatures ;
0 commit comments