Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Nov 8, 2024
1 parent 3c5d3ad commit a73b70a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions resources/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import.meta.glob(
}
);

const hasValue = (value) => {
if (typeof value === 'undefined') {
return false;
}

return value !== '' && value != 0 && value !== null;
};

export default () => ({
map: null,
tooltip: L.tooltip(),
Expand Down Expand Up @@ -43,16 +51,17 @@ export default () => ({
opacity: 0.75,
fillOpacity: 1,
color: 'white',
fillColor: this.$wire.data[feature.properties?.id]?.color || '#DDD',
fillColor: hasValue(this.$wire.data[feature.properties?.id]?.value)
? this.$wire.data[feature.properties?.id]?.color || '#DDD'
: '#DDD',
}),
onEachFeature: (feature, layer) => {
if (!feature.properties?.id) {
if (!feature.properties?.id || !hasValue(this.$wire.data[feature.properties.id]?.value)) {
return;
}

layer.bindTooltip(
`<strong>${feature.properties.name}</strong><br/>
${this.$wire.data[feature.properties.id]?.value || '&mdash;'}`,
`<strong>${feature.properties.name}</strong><br/>${this.$wire.data[feature.properties.id].value}`,
{
sticky: true,
direction: 'top',
Expand Down

0 comments on commit a73b70a

Please sign in to comment.