Skip to content

Commit

Permalink
fix(MVT): MVTStyle.layer with ref property
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Nov 25, 2024
1 parent a4bb130 commit 35ec1e6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Source/VectorTilesSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class VectorTilesSource extends TMSSource {

this.accessToken = source.accessToken;

let styleUrl;
let mvtStyleUrl;
if (source.style) {
if (typeof source.style == 'string') {
styleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken);
promise = Fetcher.json(styleUrl, this.networkOptions);
mvtStyleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken);
promise = Fetcher.json(mvtStyleUrl, this.networkOptions);
} else {
promise = Promise.resolve(source.style);
}
Expand All @@ -84,7 +84,7 @@ class VectorTilesSource extends TMSSource {
this.jsonStyle = mvtStyle;
let baseurl = source.sprite || mvtStyle.sprite;
if (baseurl) {
baseurl = new URL(baseurl, styleUrl).toString();
baseurl = new URL(baseurl, mvtStyleUrl).toString();
const spriteUrl = urlParser.normalizeSpriteURL(baseurl, '', '.json', this.accessToken);
return Fetcher.json(spriteUrl, this.networkOptions).then((sprites) => {
this.sprites = sprites;
Expand Down Expand Up @@ -114,6 +114,7 @@ class VectorTilesSource extends TMSSource {
layer[prop] = refLayer[prop];
});
}

const style = Style.setFromVectorTileLayer(layer, this.sprites, this.symbolToCircle, this.warn);
this.styles[layer.id] = style;

Expand All @@ -136,7 +137,7 @@ class VectorTilesSource extends TMSSource {
if (this.url == '.') {
const TMSUrlList = Object.values(mvtStyle.sources).map((sourceVT) => {
if (sourceVT.url) {
sourceVT.url = new URL(sourceVT.url, styleUrl).toString();
sourceVT.url = new URL(sourceVT.url, mvtStyleUrl).toString();
const urlSource = urlParser.normalizeSourceURL(sourceVT.url, this.accessToken);
return Fetcher.json(urlSource, this.networkOptions).then((tileJSON) => {
if (tileJSON.tiles[0]) {
Expand Down

0 comments on commit 35ec1e6

Please sign in to comment.