fix: don't force multi-sprites in style
Signed-off-by: acalcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
361464fd4a
commit
e9bb16936e
2 changed files with 30 additions and 11 deletions
|
@ -1046,6 +1046,9 @@ export const serve_rendered = {
|
|||
}
|
||||
|
||||
if (styleJSON.sprite) {
|
||||
if (!Array.isArray(styleJSON.sprite)) {
|
||||
styleJSON.sprite = [{ id: 'default', url: styleJSON.sprite }];
|
||||
}
|
||||
styleJSON.sprite.forEach((spriteItem) => {
|
||||
if (!httpTester.test(spriteItem.url)) {
|
||||
spriteItem.url =
|
||||
|
|
|
@ -61,9 +61,13 @@ export const serve_style = {
|
|||
}
|
||||
// mapbox-gl-js viewer cannot handle sprite urls with query
|
||||
if (styleJSON_.sprite) {
|
||||
if (Array.isArray(styleJSON_.sprite)) {
|
||||
styleJSON_.sprite.forEach((spriteItem) => {
|
||||
spriteItem.url = fixUrl(req, spriteItem.url, item.publicUrl);
|
||||
});
|
||||
} else {
|
||||
styleJSON_.sprite = fixUrl(req, styleJSON_.sprite, item.publicUrl);
|
||||
}
|
||||
}
|
||||
if (styleJSON_.glyphs) {
|
||||
styleJSON_.glyphs = fixUrl(req, styleJSON_.glyphs, item.publicUrl);
|
||||
|
@ -173,9 +177,20 @@ export const serve_style = {
|
|||
let spritePaths = [];
|
||||
if (styleJSON.sprite) {
|
||||
if (!Array.isArray(styleJSON.sprite)) {
|
||||
styleJSON.sprite = [{ id: 'default', url: styleJSON.sprite }];
|
||||
if (!httpTester.test(styleJSON.sprite)) {
|
||||
let spritePath = path.join(
|
||||
options.paths.sprites,
|
||||
styleJSON.sprite
|
||||
.replace('{style}', path.basename(styleFile, '.json'))
|
||||
.replace(
|
||||
'{styleJsonFolder}',
|
||||
path.relative(options.paths.sprites, path.dirname(styleFile)),
|
||||
),
|
||||
);
|
||||
styleJSON.sprite = `local://styles/${id}/sprite`;
|
||||
spritePaths.push({ id: 'default', path: spritePath });
|
||||
}
|
||||
|
||||
} else {
|
||||
for (let spriteItem of styleJSON.sprite) {
|
||||
if (!httpTester.test(spriteItem.url)) {
|
||||
let spritePath = path.join(
|
||||
|
@ -192,6 +207,7 @@ export const serve_style = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (styleJSON.glyphs && !httpTester.test(styleJSON.glyphs)) {
|
||||
styleJSON.glyphs = 'local://fonts/{fontstack}/{range}.pbf';
|
||||
|
|
Loading…
Reference in a new issue