@@ -3880,6 +3880,157 @@ describe('mapboxgl_WebMapV2', () => {
38803880 } ) ;
38813881 } ) ;
38823882
3883+ it ( 'overlay is TILE which carried credential token' , ( done ) => {
3884+ 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"]]` ;
3885+ const nextMapInfo = {
3886+ ...dynamicProjectionMapInfo ,
3887+ layers : dynamicProjectionMapInfo . layers . map ( item => {
3888+ return {
3889+ ...item ,
3890+ credential : {
3891+ "token" : "pBRw08Vs3-vfgqDi76tpvOYKCnLYFZ35exKFMMFV5vQ-3CWn80_xIZ_rweYxOe9t3ot0ahD2Y5Uymh50-YeyzzQkel0Ong.."
3892+ }
3893+ }
3894+ } )
3895+ } ;
3896+ spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
3897+ if ( url . indexOf ( 'portal.json' ) > - 1 ) {
3898+ return Promise . resolve ( new Response ( JSON . stringify ( iportal_serviceProxy ) ) ) ;
3899+ }
3900+ if ( url . indexOf ( '123/map.json' ) > - 1 ) {
3901+ return Promise . resolve ( new Response ( JSON . stringify ( nextMapInfo ) ) ) ;
3902+ }
3903+ if ( url . indexOf ( `prjCoordSys=${ JSON . stringify ( { epsgCode : 4326 } ) } ` ) > - 1 ) {
3904+ expect ( url ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
3905+ return Promise . resolve (
3906+ new Response (
3907+ JSON . stringify ( {
3908+ prjCoordSys : { epsgCode : 4326 } ,
3909+ bounds : {
3910+ top : 2.3755571276430945 ,
3911+ left : 113.5091647206238 ,
3912+ bottom : 2.087888705520514 ,
3913+ leftBottom : {
3914+ x : 113.5091647206238 ,
3915+ y : 2.087888705520514
3916+ } ,
3917+ right : 113.84235808224173 ,
3918+ rightTop : {
3919+ x : 113.84235808224173 ,
3920+ y : 2.3755571276430945
3921+ }
3922+ }
3923+ } )
3924+ )
3925+ ) ;
3926+ }
3927+ if ( url . indexOf ( `test.json` ) > - 1 ) {
3928+ expect ( url ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
3929+ return Promise . resolve (
3930+ new Response (
3931+ JSON . stringify ( {
3932+ prjCoordSys : { epsgCode : 4496 } ,
3933+ bounds : {
3934+ top : 262679.13362826034 ,
3935+ left : 25493.744181281887 ,
3936+ bottom : 230878.98887457885 ,
3937+ leftBottom : {
3938+ x : 25493.744181281887 ,
3939+ y : 230878.98887457885
3940+ } ,
3941+ right : 62548.98751319852 ,
3942+ rightTop : {
3943+ x : 62548.98751319852 ,
3944+ y : 262679.13362826034
3945+ }
3946+ }
3947+ } )
3948+ )
3949+ ) ;
3950+ }
3951+ if ( url . indexOf ( `China_Dark.json` ) > - 1 ) {
3952+ return Promise . resolve (
3953+ new Response (
3954+ JSON . stringify ( {
3955+ prjCoordSys : { epsgCode : - 1 } ,
3956+ bounds : {
3957+ top : 20037508.342789087 ,
3958+ left : - 20037508.342789248 ,
3959+ bottom : - 25819498.513543323 ,
3960+ leftBottom : {
3961+ x : - 20037508.342789248 ,
3962+ y : - 25819498.513543323
3963+ } ,
3964+ right : 20037508.342789244 ,
3965+ rightTop : {
3966+ x : 20037508.342789244 ,
3967+ y : 20037508.342789087
3968+ }
3969+ }
3970+ } )
3971+ )
3972+ ) ;
3973+ }
3974+ if ( url . indexOf ( `china.json` ) > - 1 ) {
3975+ expect ( url ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
3976+ return Promise . resolve (
3977+ new Response (
3978+ JSON . stringify ( {
3979+ prjCoordSys : { epsgCode : 3857 } ,
3980+ bounds : {
3981+ top : 5127400.782113583 ,
3982+ left : 10607760.850223977 ,
3983+ bottom : 2755785.4693220854 ,
3984+ leftBottom : {
3985+ x : 10607760.850223977 ,
3986+ y : 2755785.4693220854
3987+ } ,
3988+ right : 12979376.163015474 ,
3989+ rightTop : {
3990+ x : 12979376.163015474 ,
3991+ y : 5127400.782113583
3992+ }
3993+ }
3994+ } )
3995+ )
3996+ ) ;
3997+ }
3998+ if ( url . indexOf ( 'prjCoordSys.wkt' ) ) {
3999+ return Promise . resolve ( new Response ( wkt4496 ) ) ;
4000+ }
4001+ } ) ;
4002+ datavizWebmap = new WebMap ( '123' , {
4003+ target : 'map' ,
4004+ serverUrl : 'http://fake/fakeiportal' ,
4005+ withCredentials : false
4006+ } ) ;
4007+ datavizWebmap . on ( 'mapcreatesucceeded' , ( { map } ) => {
4008+ const style = map . getStyle ( ) ;
4009+ expect ( map . getStyle ( ) . layers . length ) . toBe ( 3 ) ;
4010+ const expectedBaselayerBounds = [ - 180.00000000000006 , - 88 , 180.00000000000003 , 85.05112877980648 ] ;
4011+ const actualBaselayerBounds = style . sources [ '中国暗色地图' ] . bounds ;
4012+ expect ( actualBaselayerBounds . length ) . toBe ( expectedBaselayerBounds . length ) ;
4013+ actualBaselayerBounds . forEach ( ( val , i ) => {
4014+ expect ( val ) . toBeCloseTo ( expectedBaselayerBounds [ i ] , 6 ) ;
4015+ } ) ;
4016+ const expectedOverlayer1Bounds = [ 95.29113702040888 , 24.019508369205386 , 116.5957198557339 , 41.77544139596302 ] ;
4017+ const actualOverlayer1Bounds = style . sources . china . bounds ;
4018+ expect ( actualOverlayer1Bounds . length ) . toBe ( expectedOverlayer1Bounds . length ) ;
4019+ actualOverlayer1Bounds . forEach ( ( val , i ) => {
4020+ expect ( val ) . toBeCloseTo ( expectedOverlayer1Bounds [ i ] , 6 ) ;
4021+ } ) ;
4022+ expect ( style . sources . china . tiles [ 0 ] ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
4023+ const expectedOverlayer2Bounds = [ 113.5091647206238 , 2.087888705520514 , 113.84235808224173 , 2.3755571276430945 ] ;
4024+ const actualOverlayer2Bounds = style . sources . test . bounds ;
4025+ expect ( actualOverlayer2Bounds . length ) . toBe ( expectedOverlayer2Bounds . length ) ;
4026+ actualOverlayer2Bounds . forEach ( ( val , i ) => {
4027+ expect ( val ) . toBeCloseTo ( expectedOverlayer2Bounds [ i ] , 6 ) ;
4028+ } ) ;
4029+ expect ( style . sources . test . tiles [ 0 ] ) . toContain ( `token=${ nextMapInfo . layers [ 0 ] . credential . token } ` ) ;
4030+ done ( ) ;
4031+ } ) ;
4032+ } ) ;
4033+
38834034 it ( 'baselayer is ZXY_TILE, calc zoomBase with resolutions, minScale 0' , ( done ) => {
38844035 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
38854036 if ( url . indexOf ( 'portal.json' ) > - 1 ) {
@@ -4127,4 +4278,47 @@ describe('mapboxgl_WebMapV2', () => {
41274278 done ( ) ;
41284279 } ) ;
41294280 } ) ;
4281+
4282+ it ( 'baselayer is MAPBOXSTYLE when mapInfo has no extent' , ( done ) => {
4283+ const mapInfo = {
4284+ "maxScale" : "1:144447.92746805" ,
4285+ "baseLayer" : {
4286+ "layerType" : "MAPBOXSTYLE" ,
4287+ "name" : "Capital@World33font" ,
4288+ "dataSource" : {
4289+ "type" : "EXTERNAL" ,
4290+ "url" : "http://localhost:8195/portalproxy/ad4c697aec15c20c/iserver/services/map-mvt-CapitalWorld33font/restjsr/v1/vectortile/maps/Capital%40World33font"
4291+ }
4292+ } ,
4293+ "projection" : "EPSG:4326" ,
4294+ "minScale" : "1:591658710.909131" ,
4295+ "title" : "Capital@World33font" ,
4296+ "version" : "2.3.0" ,
4297+ }
4298+ spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
4299+ if ( url . indexOf ( 'portal.json' ) > - 1 ) {
4300+ return Promise . resolve ( new Response ( JSON . stringify ( iportal_serviceProxy ) ) ) ;
4301+ }
4302+ if ( url . indexOf ( '123/map.json' ) > - 1 ) {
4303+ return Promise . resolve (
4304+ new Response (
4305+ JSON . stringify ( mapInfo )
4306+ )
4307+ ) ;
4308+ }
4309+ if ( url . indexOf ( '/style.json' ) ) {
4310+ return Promise . resolve ( new Response ( JSON . stringify ( vectorTile_style ) ) ) ;
4311+ }
4312+ return Promise . resolve ( new Response ( JSON . stringify ( { } ) ) ) ;
4313+ } ) ;
4314+ datavizWebmap = new WebMap ( '123' , {
4315+ target : 'map' ,
4316+ serverUrl : 'http://fake/fakeiportal' ,
4317+ withCredentials : false
4318+ } ) ;
4319+ datavizWebmap . on ( 'mapcreatesucceeded' , ( { map } ) => {
4320+ expect ( map ) . not . toBeUndefined ( ) ;
4321+ done ( ) ;
4322+ } ) ;
4323+ } ) ;
41304324} ) ;
0 commit comments