@@ -334,4 +334,58 @@ describe("openlayers_MapboxStyles", () => {
334334 }
335335 } ) ;
336336 } ) ;
337+
338+ it ( "handle relative url with param" , done => {
339+ spyOn ( XMLHttpRequest . prototype , 'send' ) . and . callThrough ( ) ;
340+ spyOn ( XMLHttpRequest . prototype , 'setRequestHeader' ) . and . callThrough ( ) ;
341+ var style = {
342+ "version" : 8 ,
343+ "sprite" : "../sprites/sprite" ,
344+ "glyphs" : "../fonts/{fontstack}/{range}.pbf" ,
345+ "sources" : {
346+ "esri" : {
347+ "type" : "vector" ,
348+ "url" : "../../"
349+ }
350+ } ,
351+ "layers" : [ {
352+ "id" : "Contour_11_main/0" ,
353+ "type" : "line" ,
354+ "source" : "esri" ,
355+ "source-layer" : "Contour" ,
356+ "filter" : [ "all" , [ "==" , "Index3" , 1 ] , [ "==" , "Index5" , 1 ] ] ,
357+ "minzoom" : 11 ,
358+ "maxzoom" : 12 ,
359+ "paint" : {
360+ "line-color" : "#61674a" ,
361+ "line-opacity" : 0.5 ,
362+ "line-width" : {
363+ "base" : 1.2 ,
364+ "stops" : [ [ 11 , 0.7 ] , [ 16 , 1.1 ] ]
365+ }
366+ }
367+ } ]
368+ }
369+ mapboxStyles = new MapboxStyles ( {
370+ style : style ,
371+ baseUrl : 'http://localhost:9876?tkk=ddddssss' ,
372+ map : map ,
373+ source : "California" ,
374+ headers :{ 'appToken' :'test' }
375+ } ) ;
376+ mapboxStyles . on ( "styleloaded" , ( ) => {
377+ try {
378+ style = mapboxStyles . getStyleFunction ( ) ;
379+ expect ( style ) . not . toBeNull ( ) ;
380+ expect ( mapboxStyles . _mbStyle . glyphs ) . toBe ( 'http://localhost:9876/fonts/{fontstack}/{range}.pbf?tkk=ddddssss' ) ;
381+ expect ( mapboxStyles . _mbStyle . sprite ) . toBe ( 'http://localhost:9876/sprites/sprite?tkk=ddddssss' ) ;
382+ expect ( mapboxStyles . _mbStyle . sources [ 'esri' ] [ 'url' ] ) . toBe ( 'http://localhost:9876/?tkk=ddddssss' ) ;
383+ done ( ) ;
384+ } catch ( e ) {
385+ console . log ( "'init_Style_headers'案例失败" + e . name + ":" + e . message ) ;
386+ expect ( false ) . toBeTruthy ( ) ;
387+ done ( ) ;
388+ }
389+ } ) ;
390+ } ) ;
337391} ) ;
0 commit comments