@@ -71,9 +71,10 @@ class VectorTilesSource extends TMSSource {
7171
7272 this . accessToken = source . accessToken ;
7373
74+ let styleUrl ;
7475 if ( source . style ) {
7576 if ( typeof source . style == 'string' ) {
76- const styleUrl = urlParser . normalizeStyleURL ( source . style , this . accessToken ) ;
77+ styleUrl = urlParser . normalizeStyleURL ( source . style , this . accessToken ) ;
7778 promise = Fetcher . json ( styleUrl , this . networkOptions ) ;
7879 } else {
7980 promise = Promise . resolve ( source . style ) ;
@@ -84,8 +85,9 @@ class VectorTilesSource extends TMSSource {
8485
8586 this . whenReady = promise . then ( ( style ) => {
8687 this . jsonStyle = style ;
87- const baseurl = source . sprite || style . sprite ;
88+ let baseurl = source . sprite || style . sprite ;
8889 if ( baseurl ) {
90+ baseurl = new URL ( baseurl , styleUrl ) . toString ( ) ;
8991 const spriteUrl = urlParser . normalizeSpriteURL ( baseurl , '' , '.json' , this . accessToken ) ;
9092 return Fetcher . json ( spriteUrl , this . networkOptions ) . then ( ( sprites ) => {
9193 this . sprites = sprites ;
@@ -123,9 +125,11 @@ class VectorTilesSource extends TMSSource {
123125 if ( this . url == '.' ) {
124126 const TMSUrlList = Object . values ( style . sources ) . map ( ( sourceVT ) => {
125127 if ( sourceVT . url ) {
128+ sourceVT . url = new URL ( sourceVT . url , styleUrl ) . toString ( ) ;
126129 const urlSource = urlParser . normalizeSourceURL ( sourceVT . url , this . accessToken ) ;
127130 return Fetcher . json ( urlSource , this . networkOptions ) . then ( ( tileJSON ) => {
128131 if ( tileJSON . tiles [ 0 ] ) {
132+ tileJSON . tiles [ 0 ] = decodeURIComponent ( new URL ( tileJSON . tiles [ 0 ] , urlSource ) . toString ( ) ) ;
129133 return toTMSUrl ( tileJSON . tiles [ 0 ] ) ;
130134 }
131135 } ) ;
0 commit comments