1+
12import { webMap } from '../../../src/leaflet/mapping/WebMap' ;
23import { FetchRequest } from '../../../src/common/util/FetchRequest' ;
34import { mockCreateTile , mockHeatLayer } from '../../tool/mock_leaflet' ;
@@ -24,12 +25,11 @@ describe('leaflet_WebMap', () => {
2425 jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
2526 } ) ;
2627 afterEach ( ( ) => {
27- map = null ;
2828 window . document . body . removeChild ( testDiv ) ;
2929 jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
3030 } ) ;
3131
32- it ( 'getResolutionsFromScales' , ( ) => {
32+ it ( 'getResolutionsFromScales' , ( ) => {
3333 map = webMap ( ) ;
3434 var scales = [ 2.9582935545E8 , 1.47914677725E8 , 7.39573388625E7 , 3.697866943125E7 , 1.8489334715625E7 ] ,
3535 units = "meter" ;
@@ -42,7 +42,7 @@ describe('leaflet_WebMap', () => {
4242 expect ( resolutions [ 4 ] ) . toEqual ( 4891.969810175781 ) ;
4343 } ) ;
4444
45- it ( 'initialize_SUPERMAP_REST' , ( done ) => {
45+ it ( 'initialize_SUPERMAP_REST' , ( done ) => {
4646 var id = 55 ;
4747 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
4848 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -52,7 +52,7 @@ describe('leaflet_WebMap', () => {
5252 return Promise . resolve ( ) ;
5353 } ) ;
5454 map = webMap ( id , { server : server } ) ;
55- setTimeout ( ( ) => {
55+ map . on ( 'maploaded' , ( ) => {
5656 expect ( map . id ) . toEqual ( 55 ) ;
5757 expect ( map . layers . length ) . toEqual ( 0 ) ;
5858 var mapInfo = map . mapInfo ;
@@ -86,10 +86,10 @@ describe('leaflet_WebMap', () => {
8686 expect ( mapInfo . userName ) . toBe ( "testH" ) ;
8787 expect ( map . options . server ) . toBe ( server ) ;
8888 done ( ) ;
89- } , 0 )
89+ } )
9090 } ) ;
9191
92- it ( 'initialize_TIANDITU_VEC' , ( done ) => {
92+ it ( 'initialize_TIANDITU_VEC' , ( done ) => {
9393 var id = 568205813 ;
9494 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
9595 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -99,7 +99,7 @@ describe('leaflet_WebMap', () => {
9999 return Promise . resolve ( ) ;
100100 } ) ;
101101 map = webMap ( id , { server : server } ) ;
102- setTimeout ( ( ) => {
102+ map . on ( 'maploaded' , ( ) => {
103103 expect ( map . id ) . toBe ( id ) ;
104104 var mapInfo = map . mapInfo ;
105105 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -132,10 +132,10 @@ describe('leaflet_WebMap', () => {
132132 expect ( mapInfo . userName ) . toBe ( "361143" ) ;
133133 expect ( map . options . server ) . toBe ( server ) ;
134134 done ( ) ;
135- } , 0 ) ;
135+ } )
136136 } ) ;
137137
138- it ( 'initialize_TIANDITU_IMG' , ( done ) => {
138+ it ( 'initialize_TIANDITU_IMG' , ( done ) => {
139139 var id = 567946816 ;
140140 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
141141 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -145,7 +145,7 @@ describe('leaflet_WebMap', () => {
145145 return Promise . resolve ( ) ;
146146 } ) ;
147147 map = webMap ( id , { server : server } ) ;
148- setTimeout ( ( ) => {
148+ map . on ( 'maploaded' , ( ) => {
149149 expect ( map . id ) . toBe ( id ) ;
150150 var mapInfo = map . mapInfo ;
151151 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -178,10 +178,10 @@ describe('leaflet_WebMap', () => {
178178 expect ( mapInfo . userName ) . toBe ( "361143" ) ;
179179 expect ( map . options . server ) . toBe ( server ) ;
180180 done ( ) ;
181- } , 0 ) ;
181+ } )
182182 } ) ;
183183
184- it ( 'initialize_TIANDITU_TER' , ( done ) => {
184+ it ( 'initialize_TIANDITU_TER' , ( done ) => {
185185 var id = 2048499925 ;
186186 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
187187 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -191,7 +191,7 @@ describe('leaflet_WebMap', () => {
191191 return Promise . resolve ( ) ;
192192 } ) ;
193193 map = webMap ( id , { server : server } ) ;
194- setTimeout ( ( ) => {
194+ map . on ( 'maploaded' , ( ) => {
195195 expect ( map . id ) . toBe ( id ) ;
196196 var mapInfo = map . mapInfo ;
197197 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -224,10 +224,10 @@ describe('leaflet_WebMap', () => {
224224 expect ( mapInfo . userName ) . toBe ( "361143" ) ;
225225 expect ( map . options . server ) . toBe ( server ) ;
226226 done ( ) ;
227- } , 0 ) ;
227+ } )
228228 } ) ;
229229
230- it ( 'initialize_BAIDU' , ( done ) => {
230+ it ( 'initialize_BAIDU' , ( done ) => {
231231 var id = 1123771109 ;
232232 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
233233 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -237,7 +237,7 @@ describe('leaflet_WebMap', () => {
237237 return Promise . resolve ( ) ;
238238 } ) ;
239239 map = webMap ( id , { server : server } ) ;
240- setTimeout ( ( ) => {
240+ map . on ( 'maploaded' , ( ) => {
241241 expect ( map . id ) . toBe ( id ) ;
242242 var mapInfo = map . mapInfo ;
243243 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -270,10 +270,10 @@ describe('leaflet_WebMap', () => {
270270 expect ( mapInfo . userName ) . toBe ( "361143" ) ;
271271 expect ( map . options . server ) . toBe ( server ) ;
272272 done ( ) ;
273- } , 0 ) ;
273+ } )
274274 } ) ;
275275
276- it ( 'initialize_WMS' , ( done ) => {
276+ it ( 'initialize_WMS' , ( done ) => {
277277 var id = 419 ;
278278 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
279279 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -283,7 +283,7 @@ describe('leaflet_WebMap', () => {
283283 return Promise . resolve ( ) ;
284284 } ) ;
285285 map = webMap ( id , { server : server } ) ;
286- setTimeout ( ( ) => {
286+ map . on ( 'maploaded' , ( ) => {
287287 expect ( map . id ) . toEqual ( 419 ) ;
288288 expect ( map . layers . length ) . toEqual ( 0 ) ;
289289 var mapInfo = map . mapInfo ;
@@ -320,7 +320,7 @@ describe('leaflet_WebMap', () => {
320320 } , 0 )
321321 } ) ;
322322
323- it ( 'initialize_WMTS' , ( done ) => {
323+ it ( 'initialize_WMTS' , ( done ) => {
324324 var id = 612 ;
325325 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
326326 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -330,7 +330,7 @@ describe('leaflet_WebMap', () => {
330330 return Promise . resolve ( ) ;
331331 } ) ;
332332 map = webMap ( id , { server : server } ) ;
333- setTimeout ( ( ) => {
333+ map . on ( 'maploaded' , ( ) => {
334334 expect ( map . id ) . toEqual ( 612 ) ;
335335 expect ( map . layers . length ) . toEqual ( 0 ) ;
336336 var mapInfo = map . mapInfo ;
@@ -367,7 +367,7 @@ describe('leaflet_WebMap', () => {
367367 } , 0 )
368368 } ) ;
369369
370- it ( 'initialize_CLOUD' , ( done ) => {
370+ it ( 'initialize_CLOUD' , ( done ) => {
371371 var id = 359319824 ;
372372 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
373373 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -377,7 +377,7 @@ describe('leaflet_WebMap', () => {
377377 return Promise . resolve ( ) ;
378378 } ) ;
379379 map = webMap ( id , { server : server } ) ;
380- setTimeout ( ( ) => {
380+ map . on ( 'maploaded' , ( ) => {
381381 expect ( map . id ) . toBe ( id ) ;
382382 var mapInfo = map . mapInfo ;
383383 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -413,7 +413,7 @@ describe('leaflet_WebMap', () => {
413413 } , 0 )
414414 } ) ;
415415
416- it ( 'CLOUD add FEATURE_LAYER' , ( done ) => {
416+ it ( 'CLOUD add FEATURE_LAYER' , ( done ) => {
417417 var id = 840 ;
418418 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
419419 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -423,7 +423,7 @@ describe('leaflet_WebMap', () => {
423423 return Promise . resolve ( ) ;
424424 } ) ;
425425 map = webMap ( id , { server : server } ) ;
426- setTimeout ( ( ) => {
426+ map . on ( 'maploaded' , ( ) => {
427427 expect ( map . id ) . toBe ( id ) ;
428428 var mapInfo = map . mapInfo ;
429429 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -454,7 +454,7 @@ describe('leaflet_WebMap', () => {
454454 } , 0 )
455455 } ) ;
456456
457- it ( 'SUPERMAP_REST add MARKER_LAYER' , ( done ) => {
457+ it ( 'SUPERMAP_REST add MARKER_LAYER' , ( done ) => {
458458 var id = 370 ;
459459 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
460460 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -464,7 +464,7 @@ describe('leaflet_WebMap', () => {
464464 return Promise . resolve ( ) ;
465465 } ) ;
466466 map = webMap ( id , { server : server } ) ;
467- setTimeout ( ( ) => {
467+ map . on ( 'maploaded' , ( ) => {
468468 expect ( map . id ) . toBe ( id ) ;
469469 var mapInfo = map . mapInfo ;
470470 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -496,7 +496,7 @@ describe('leaflet_WebMap', () => {
496496 } , 0 )
497497 } ) ;
498498
499- it ( 'createThemeLayer_HeatLayer' , ( done ) => {
499+ it ( 'createThemeLayer_HeatLayer' , ( done ) => {
500500 var id = 2489 ;
501501 mockHeatLayer ( ) ;
502502 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
@@ -507,7 +507,7 @@ describe('leaflet_WebMap', () => {
507507 return Promise . resolve ( ) ;
508508 } ) ;
509509 map = webMap ( id , { server : server } ) ;
510- setTimeout ( ( ) => {
510+ map . on ( 'maploaded' , ( ) => {
511511 expect ( map . id ) . toBe ( id ) ;
512512 var mapInfo = map . mapInfo ;
513513 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -534,12 +534,12 @@ describe('leaflet_WebMap', () => {
534534 expect ( mapInfo . title ) . toBe ( "北京高校分布热点图" ) ;
535535 expect ( mapInfo . userName ) . toBe ( "48372" ) ;
536536 expect ( map . options . server ) . toBe ( server ) ;
537- map = null ;
537+
538538 done ( ) ;
539539 } , 0 )
540540 } ) ;
541541
542- it ( 'createThemeLayer_UniqueLayer' , ( done ) => {
542+ it ( 'createThemeLayer_UniqueLayer' , ( done ) => {
543543 var id = 1765 ;
544544 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
545545 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -549,7 +549,7 @@ describe('leaflet_WebMap', () => {
549549 return Promise . resolve ( ) ;
550550 } ) ;
551551 map = webMap ( id , { server : server } ) ;
552- setTimeout ( ( ) => {
552+ map . on ( 'maploaded' , ( ) => {
553553 expect ( map . id ) . toBe ( id ) ;
554554 var mapInfo = map . mapInfo ;
555555 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -576,7 +576,7 @@ describe('leaflet_WebMap', () => {
576576 expect ( mapInfo . title ) . toBe ( "北京高校分布热点图" ) ;
577577 expect ( mapInfo . userName ) . toBe ( "48372" ) ;
578578 expect ( map . options . server ) . toBe ( server ) ;
579- map = null ;
579+ //
580580 done ( ) ;
581581 } , 0 )
582582 } ) ;
@@ -591,7 +591,7 @@ describe('leaflet_WebMap', () => {
591591 return Promise . resolve ( ) ;
592592 } ) ;
593593 map = webMap ( id , { server : server } ) ;
594- setTimeout ( ( ) => {
594+ map . on ( 'maploaded' , ( ) => {
595595 expect ( map . id ) . toBe ( id ) ;
596596 var mapInfo = map . mapInfo ;
597597 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -617,12 +617,12 @@ describe('leaflet_WebMap', () => {
617617 expect ( mapInfo . title ) . toBe ( "北京三级甲等医院" ) ;
618618 expect ( mapInfo . userName ) . toBe ( "10047" ) ;
619619 expect ( map . options . server ) . toBe ( server ) ;
620- map = null ;
620+
621621 done ( ) ;
622622 } , 0 )
623623 } ) ;
624624
625- it ( 'createThemeLayer_VectorThemeLayer' , ( done ) => {
625+ it ( 'createThemeLayer_VectorThemeLayer' , ( done ) => {
626626 var id = 1765 ;
627627 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
628628 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -633,7 +633,7 @@ describe('leaflet_WebMap', () => {
633633 } ) ;
634634
635635 map = webMap ( id , { server : server } ) ;
636- setTimeout ( ( ) => {
636+ map . on ( 'maploaded' , ( ) => {
637637 expect ( map . id ) . toBe ( id ) ;
638638 var mapInfo = map . mapInfo ;
639639 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 2 ) ;
@@ -665,7 +665,7 @@ describe('leaflet_WebMap', () => {
665665 } , 0 )
666666 } ) ;
667667
668- it ( 'createThemeLayer_LabelLayer' , ( done ) => {
668+ it ( 'createThemeLayer_LabelLayer' , ( done ) => {
669669 var id = 2489 ;
670670 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
671671 if ( url === server + "/web/maps/" + id + ".json" ) {
@@ -675,7 +675,7 @@ describe('leaflet_WebMap', () => {
675675 return Promise . resolve ( ) ;
676676 } ) ;
677677 map = webMap ( id , { server : server } ) ;
678- setTimeout ( ( ) => {
678+ map . on ( 'maploaded' , ( ) => {
679679 expect ( map . id ) . toBe ( id ) ;
680680 var mapInfo = map . mapInfo ;
681681 expect ( mapInfo . authorizeSetting . length ) . toEqual ( 4 ) ;
0 commit comments