@@ -260,7 +260,7 @@ export class MapService implements IMapService {
260260 }
261261 }
262262
263- async generateStylesJSON ( host : string | null = null ) : Promise < BaseStylesFile > {
263+ async generateStylesJSON ( host : string | null = null , protocol : string = 'http' ) : Promise < BaseStylesFile > {
264264 if ( ! ( await this . checkBaseAssetsExist ( ) ) ) {
265265 throw new Error ( 'Base map assets are missing from storage/maps' )
266266 }
@@ -281,8 +281,8 @@ export class MapService implements IMapService {
281281 * e.g. user is accessing from "example.com", but we would by default generate "localhost:8080/..." so maps would
282282 * fail to load.
283283 */
284- const sources = this . generateSourcesArray ( host , regions )
285- const baseUrl = this . getPublicFileBaseUrl ( host , this . basemapsAssetsDir )
284+ const sources = this . generateSourcesArray ( host , regions , protocol )
285+ const baseUrl = this . getPublicFileBaseUrl ( host , this . basemapsAssetsDir , protocol )
286286
287287 const styles = await this . generateStylesFile (
288288 rawStyles ,
@@ -342,9 +342,9 @@ export class MapService implements IMapService {
342342 return await listDirectoryContentsRecursive ( this . baseDirPath )
343343 }
344344
345- private generateSourcesArray ( host : string | null , regions : FileEntry [ ] ) : BaseStylesFile [ 'sources' ] [ ] {
345+ private generateSourcesArray ( host : string | null , regions : FileEntry [ ] , protocol : string = 'http' ) : BaseStylesFile [ 'sources' ] [ ] {
346346 const sources : BaseStylesFile [ 'sources' ] [ ] = [ ]
347- const baseUrl = this . getPublicFileBaseUrl ( host , 'pmtiles' )
347+ const baseUrl = this . getPublicFileBaseUrl ( host , 'pmtiles' , protocol )
348348
349349 for ( const region of regions ) {
350350 if ( region . type === 'file' && region . name . endsWith ( '.pmtiles' ) ) {
@@ -433,7 +433,7 @@ export class MapService implements IMapService {
433433 /*
434434 * Gets the appropriate public URL for a map asset depending on environment
435435 */
436- private getPublicFileBaseUrl ( specifiedHost : string | null , childPath : string ) : string {
436+ private getPublicFileBaseUrl ( specifiedHost : string | null , childPath : string , protocol : string = 'http' ) : string {
437437 function getHost ( ) {
438438 try {
439439 const localUrlRaw = env . get ( 'URL' )
@@ -447,7 +447,7 @@ export class MapService implements IMapService {
447447 }
448448
449449 const host = specifiedHost || getHost ( )
450- const withProtocol = host . startsWith ( 'http' ) ? host : `http ://${ host } `
450+ const withProtocol = host . startsWith ( 'http' ) ? host : `${ protocol } ://${ host } `
451451 const baseUrlPath =
452452 process . env . NODE_ENV === 'production' ? childPath : urlJoin ( this . mapStoragePath , childPath )
453453
0 commit comments