Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
fix(labels): reverts sources order (#18)
Browse files Browse the repository at this point in the history
When multiple sources are used, labels were defined in rendering order. That means that the bottom layer labels had precedence over the top layer ones. This changes it to make the top ones have precedence
  • Loading branch information
ibesora authored Mar 28, 2022
1 parent 9368667 commit e1c1f35
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion dist/frontends/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ const leafletLayer = (options) => {
console.warn("Overwritting the basemap using updateDataSources will result in duplicated rules");
this.views.set(d.name, sourceToView(d.options));
this.paint_rules = this.paint_rules.concat(d.paintRules);
dataLabelRules.push(...d.labelRules);
// We want top layer labels to be shown first so we need to reverse label rules
// order
dataLabelRules.unshift(...d.labelRules);
});
if (dataLabelRules.length !== 0) {
this.label_rules = dataLabelsOnTop
Expand Down
2 changes: 1 addition & 1 deletion dist/protomaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5105,7 +5105,7 @@ var protomaps = (() => {
console.warn("Overwritting the basemap using updateDataSources will result in duplicated rules");
this.views.set(d.name, sourceToView(d.options));
this.paint_rules = this.paint_rules.concat(d.paintRules);
dataLabelRules.push(...d.labelRules);
dataLabelRules.unshift(...d.labelRules);
});
if (dataLabelRules.length !== 0) {
this.label_rules = dataLabelsOnTop ? dataLabelRules.concat(this.label_rules) : this.label_rules.concat(dataLabelRules);
Expand Down
2 changes: 1 addition & 1 deletion dist/protomaps.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/protomaps.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -5030,7 +5030,7 @@ var leafletLayer = (options) => {
console.warn("Overwritting the basemap using updateDataSources will result in duplicated rules");
this.views.set(d.name, sourceToView(d.options));
this.paint_rules = this.paint_rules.concat(d.paintRules);
dataLabelRules.push(...d.labelRules);
dataLabelRules.unshift(...d.labelRules);
});
if (dataLabelRules.length !== 0) {
this.label_rules = dataLabelsOnTop ? dataLabelRules.concat(this.label_rules) : this.label_rules.concat(dataLabelRules);
Expand Down
4 changes: 3 additions & 1 deletion src/frontends/leaflet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ const leafletLayer = (options: any): any => {
);
this.views.set(d.name, sourceToView(d.options));
this.paint_rules = this.paint_rules.concat(d.paintRules);
dataLabelRules.push(...d.labelRules);
// We want top layer labels to be shown first so we need to reverse label rules
// order
dataLabelRules.unshift(...d.labelRules);
});

if (dataLabelRules.length !== 0) {
Expand Down

0 comments on commit e1c1f35

Please sign in to comment.