@@ -3874,6 +3874,157 @@ it('add rangeLayer last end === fieldValue', (done) => {
38743874 } ) ;
38753875 } ) ;
38763876
3877+ it ( 'overlay is TILE which carried credential token' , ( done ) => {
3878+ const wkt4496 = `PROJCS["GK Zone 18 (CGCS2000)",GEOGCS["GCS_China_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101,AUTHORITY["EPSG","7044"]]],PRIMEM["Greenwich",0.0,AUTHORITY["EPSG","8901"]],UNIT["DEGREE",0.017453292519943295],AUTHORITY["EPSG","4490"]],PROJECTION["Transverse_Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["False_Easting",1.85E7],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",105.0],PARAMETER["Latitude_Of_Origin",0.0],PARAMETER["Scale_Factor",1.0],UNIT["METER",1.0],AUTHORITY["EPSG","4496"]]` ;
3879+ const nextMapInfo = {
3880+ ...dynamicProjectionMapInfo ,
3881+ layers : dynamicProjectionMapInfo . layers . map ( item => {
3882+ return {
3883+ ...item ,
3884+ credential : {
3885+ "token" : "pBRw08Vs3-vfgqDi76tpvOYKCnLYFZ35exKFMMFV5vQ-3CWn80_xIZ_rweYxOe9t3ot0ahD2Y5Uymh50-YeyzzQkel0Ong.."
3886+ }
3887+ }
3888+ } )
3889+ } ;
3890+ spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
3891+ if ( url . indexOf ( 'portal.json' ) > - 1 ) {
3892+ return Promise . resolve ( new Response ( JSON . stringify ( iportal_serviceProxy ) ) ) ;
3893+ }
3894+ if ( url . indexOf ( '123/map.json' ) > - 1 ) {
3895+ return Promise . resolve ( new Response ( JSON . stringify ( nextMapInfo ) ) ) ;
3896+ }
3897+ if ( url . indexOf ( `prjCoordSys=${ JSON . stringify ( { epsgCode : 4326 } ) } ` ) > - 1 ) {
3898+ expect ( url ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
3899+ return Promise . resolve (
3900+ new Response (
3901+ JSON . stringify ( {
3902+ prjCoordSys : { epsgCode : 4326 } ,
3903+ bounds : {
3904+ top : 2.3755571276430945 ,
3905+ left : 113.5091647206238 ,
3906+ bottom : 2.087888705520514 ,
3907+ leftBottom : {
3908+ x : 113.5091647206238 ,
3909+ y : 2.087888705520514
3910+ } ,
3911+ right : 113.84235808224173 ,
3912+ rightTop : {
3913+ x : 113.84235808224173 ,
3914+ y : 2.3755571276430945
3915+ }
3916+ }
3917+ } )
3918+ )
3919+ ) ;
3920+ }
3921+ if ( url . indexOf ( `test.json` ) > - 1 ) {
3922+ expect ( url ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
3923+ return Promise . resolve (
3924+ new Response (
3925+ JSON . stringify ( {
3926+ prjCoordSys : { epsgCode : 4496 } ,
3927+ bounds : {
3928+ top : 262679.13362826034 ,
3929+ left : 25493.744181281887 ,
3930+ bottom : 230878.98887457885 ,
3931+ leftBottom : {
3932+ x : 25493.744181281887 ,
3933+ y : 230878.98887457885
3934+ } ,
3935+ right : 62548.98751319852 ,
3936+ rightTop : {
3937+ x : 62548.98751319852 ,
3938+ y : 262679.13362826034
3939+ }
3940+ }
3941+ } )
3942+ )
3943+ ) ;
3944+ }
3945+ if ( url . indexOf ( `China_Dark.json` ) > - 1 ) {
3946+ return Promise . resolve (
3947+ new Response (
3948+ JSON . stringify ( {
3949+ prjCoordSys : { epsgCode : - 1 } ,
3950+ bounds : {
3951+ top : 20037508.342789087 ,
3952+ left : - 20037508.342789248 ,
3953+ bottom : - 25819498.513543323 ,
3954+ leftBottom : {
3955+ x : - 20037508.342789248 ,
3956+ y : - 25819498.513543323
3957+ } ,
3958+ right : 20037508.342789244 ,
3959+ rightTop : {
3960+ x : 20037508.342789244 ,
3961+ y : 20037508.342789087
3962+ }
3963+ }
3964+ } )
3965+ )
3966+ ) ;
3967+ }
3968+ if ( url . indexOf ( `china.json` ) > - 1 ) {
3969+ expect ( url ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
3970+ return Promise . resolve (
3971+ new Response (
3972+ JSON . stringify ( {
3973+ prjCoordSys : { epsgCode : 3857 } ,
3974+ bounds : {
3975+ top : 5127400.782113583 ,
3976+ left : 10607760.850223977 ,
3977+ bottom : 2755785.4693220854 ,
3978+ leftBottom : {
3979+ x : 10607760.850223977 ,
3980+ y : 2755785.4693220854
3981+ } ,
3982+ right : 12979376.163015474 ,
3983+ rightTop : {
3984+ x : 12979376.163015474 ,
3985+ y : 5127400.782113583
3986+ }
3987+ }
3988+ } )
3989+ )
3990+ ) ;
3991+ }
3992+ if ( url . indexOf ( 'prjCoordSys.wkt' ) ) {
3993+ return Promise . resolve ( new Response ( wkt4496 ) ) ;
3994+ }
3995+ } ) ;
3996+ datavizWebmap = new WebMap ( '123' , {
3997+ target : 'map' ,
3998+ serverUrl : 'http://fake/fakeiportal' ,
3999+ withCredentials : false
4000+ } ) ;
4001+ datavizWebmap . on ( 'mapcreatesucceeded' , ( { map } ) => {
4002+ const style = map . getStyle ( ) ;
4003+ expect ( map . getStyle ( ) . layers . length ) . toBe ( 3 ) ;
4004+ const expectedBaselayerBounds = [ - 180.00000000000006 , - 88 , 180.00000000000003 , 85.05112877980648 ] ;
4005+ const actualBaselayerBounds = style . sources [ '中国暗色地图' ] . bounds ;
4006+ expect ( actualBaselayerBounds . length ) . toBe ( expectedBaselayerBounds . length ) ;
4007+ actualBaselayerBounds . forEach ( ( val , i ) => {
4008+ expect ( val ) . toBeCloseTo ( expectedBaselayerBounds [ i ] , 6 ) ;
4009+ } ) ;
4010+ const expectedOverlayer1Bounds = [ 95.29113702040888 , 24.019508369205386 , 116.5957198557339 , 41.77544139596302 ] ;
4011+ const actualOverlayer1Bounds = style . sources . china . bounds ;
4012+ expect ( actualOverlayer1Bounds . length ) . toBe ( expectedOverlayer1Bounds . length ) ;
4013+ actualOverlayer1Bounds . forEach ( ( val , i ) => {
4014+ expect ( val ) . toBeCloseTo ( expectedOverlayer1Bounds [ i ] , 6 ) ;
4015+ } ) ;
4016+ expect ( style . sources . china . tiles [ 0 ] ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
4017+ const expectedOverlayer2Bounds = [ 113.5091647206238 , 2.087888705520514 , 113.84235808224173 , 2.3755571276430945 ] ;
4018+ const actualOverlayer2Bounds = style . sources . test . bounds ;
4019+ expect ( actualOverlayer2Bounds . length ) . toBe ( expectedOverlayer2Bounds . length ) ;
4020+ actualOverlayer2Bounds . forEach ( ( val , i ) => {
4021+ expect ( val ) . toBeCloseTo ( expectedOverlayer2Bounds [ i ] , 6 ) ;
4022+ } ) ;
4023+ expect ( style . sources . test . tiles [ 0 ] ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
4024+ done ( ) ;
4025+ } ) ;
4026+ } ) ;
4027+
38774028 it ( 'baselayer is ZXY_TILE, calc zoomBase with resolutions, minScale 0' , ( done ) => {
38784029 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
38794030 if ( url . indexOf ( 'portal.json' ) > - 1 ) {
0 commit comments