Skip to content

Commit

Permalink
fix: make function more descriptive #221
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckMt committed Mar 18, 2024
1 parent 7aa82b0 commit d79d59f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions projects/map-maplibre/src/lib/maplibre-layers.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export function createLayersFromGeojsonTypes(feature: GeoJSONFeature, l: ukisLay
'circle-radius': 5
} as const;

const getFeaturePropStyle = <T>(prop: keyof typeof defaultStyle) => {
const style: DataDrivenPropertyValueSpecification<T> = ['coalesce', ['get', prop], defaultStyle[prop]];
const coalesce = <T>(key: keyof typeof defaultStyle) => {
const style: DataDrivenPropertyValueSpecification<T> = ['coalesce', ['get', key], defaultStyle[key]];
return style;
}

Expand All @@ -286,7 +286,7 @@ export function createLayersFromGeojsonTypes(feature: GeoJSONFeature, l: ukisLay
source: l.id,
paint: {
'fill-opacity': l.opacity,
'fill-color': getFeaturePropStyle('fill')
'fill-color': coalesce('fill')
},
layout: {
visibility: (l.visible) ? 'visible' : 'none'
Expand All @@ -305,8 +305,8 @@ export function createLayersFromGeojsonTypes(feature: GeoJSONFeature, l: ukisLay
source: l.id,
paint: {
'line-opacity': l.opacity,
'line-color': getFeaturePropStyle('stroke'),
'line-width': getFeaturePropStyle('stroke-width')
'line-color': coalesce('stroke'),
'line-width': coalesce('stroke-width')
},
layout: {
'line-join': 'round',
Expand All @@ -327,10 +327,10 @@ export function createLayersFromGeojsonTypes(feature: GeoJSONFeature, l: ukisLay
paint: {
'circle-opacity': l.opacity,
'circle-stroke-opacity': l.opacity,
'circle-stroke-color': getFeaturePropStyle('stroke'),
'circle-color': getFeaturePropStyle('fill'),
'circle-radius': getFeaturePropStyle('circle-radius'),
'circle-stroke-width': getFeaturePropStyle('stroke-width'),
'circle-stroke-color': coalesce('stroke'),
'circle-color': coalesce('fill'),
'circle-radius': coalesce('circle-radius'),
'circle-stroke-width': coalesce('stroke-width'),
},
layout: {
visibility: (l.visible) ? 'visible' : 'none'
Expand Down

0 comments on commit d79d59f

Please sign in to comment.