Skip to content

Commit

Permalink
fix(VTSource): linked to review
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Jan 6, 2025
1 parent 00d592e commit 829a37e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Source/VectorTilesSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ function mergeCollections(collections) {
return collection;
}

// A deprecated (but still in use) Mapbox spec allows using 'ref' as a propertie to reference an other layer
// instead of duplicating the following properties: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'
function getPropertiesFromRefLayer(layers, layer) {
const refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];
const refLayer = layers.filter(l => l.id === layer.ref)[0];
refProperties.forEach((prop) => {
layer[prop] = refLayer[prop];
});
}

/**
* VectorTilesSource are object containing informations on how to fetch vector
* tiles resources.
Expand Down Expand Up @@ -105,11 +115,7 @@ class VectorTilesSource extends TMSSource {
this.backgroundLayer = layer;
} else if (ffilter(layer)) {
if (layer['source-layer'] === undefined) {
const refProperties = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];
const refLayer = mvtStyle.layers.filter(l => l.id === layer.ref)[0];
refProperties.forEach((prop) => {
layer[prop] = refLayer[prop];
});
getPropertiesFromRefLayer(mvtStyle.layers, layer);
}
const style = Style.setFromVectorTileLayer(layer, this.sprites, this.symbolToCircle);
this.styles[layer.id] = style;
Expand Down

0 comments on commit 829a37e

Please sign in to comment.