Skip to content

Commit

Permalink
fix: manage all possible label symbolizers
Browse files Browse the repository at this point in the history
  • Loading branch information
claustres committed Jul 18, 2024
1 parent b21c6b4 commit 195f8c7
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions map/client/mixins/map/mixin.pmtiles-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,15 @@ export const pmtilesLayers = {
}
_.set(leafletOptions, entry.property, f)
})
const isLabelSymbolizer = (rule) => rule.symbolizer.type.includes('Label') || rule.symbolizer.type.includes('Text')
const styleRules = _.map(style, rule => Object.assign(_.omit(rule, ['symbolizer']), {
symbolizer: new protomaps[rule.symbolizer.type](rule.symbolizer)
})
)
const isLabelSymbolizer = (rule) => typeof rule.symbolizer.place === 'function'
const isNotLabelSymbolizer = (rule) => !isLabelSymbolizer(rule)
// Support v1.x as well as v2.x
rules.paint_rules = rules.paintRules = _.map(_.filter(style, isNotLabelSymbolizer), paintRule => {
return Object.assign(_.omit(paintRule, ['symbolizer']), {
symbolizer: new protomaps[paintRule.symbolizer.type](paintRule.symbolizer)
})
})
rules.label_rules = rules.labelRules = _.map(_.filter(style, isLabelSymbolizer), labelRule => {
return Object.assign(_.omit(labelRule, ['symbolizer']), {
symbolizer: new protomaps[labelRule.symbolizer.type](labelRule.symbolizer)
})
})
rules.paint_rules = rules.paintRules = _.filter(styleRules, isNotLabelSymbolizer)
rules.label_rules = rules.labelRules = _.filter(styleRules, isLabelSymbolizer)
}

return this.createLeafletLayer({
Expand Down

0 comments on commit 195f8c7

Please sign in to comment.