Skip to content

Commit

Permalink
Use a custom cluster marker style (#1664)
Browse files Browse the repository at this point in the history
* feat(marker-cluster): use more consistent style

* fix(Markers): remove unused classes

we no longer differenciate
on the number of markers in a group
  • Loading branch information
mxdvl authored May 17, 2024
1 parent bf1bff8 commit a1b4e94
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/components/LooMap/Markers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Markers = () => {
boundingBoxWest,
boundingBoxNorth,
boundingBoxEast,
geohashPrecision
geohashPrecision,
);
}, [
boundingBoxEast,
Expand Down Expand Up @@ -131,7 +131,7 @@ const MarkerGroup: React.FC<{
}),
alt: 'Public Toilet',
keyboard: false,
}
},
)
.on('click', () => {
// Clear the current search upon navigation
Expand All @@ -151,20 +151,20 @@ const MarkerGroup: React.FC<{
marker.getElement()?.setAttribute('aria-label', 'Public Toilet');
return marker;
},
[router, setMapState]
[router, setMapState],
);

const [appliedFilterTypes, setAppliedFilterTypes] = useState<
Array<FILTER_TYPE>
>(
getAppliedFiltersAsFilterTypes(
config.filters.filter((filter) => filters?.[filter.id])
)
config.filters.filter((filter) => filters?.[filter.id]),
),
);

useEffect(() => {
const applied: Array<Filter> = config.filters.filter(
(filter) => filters?.[filter.id]
(filter) => filters?.[filter.id],
);
const appliedFilterTypes = getAppliedFiltersAsFilterTypes(applied);
window.setTimeout(() => {
Expand All @@ -180,7 +180,7 @@ const MarkerGroup: React.FC<{
const parsedAndFilteredMarkers = data?.loosByGeohash
.map(parseCompressedLoo)
.filter((compressedLoo) =>
filterCompressedLooByAppliedFilters(compressedLoo, appliedFilterTypes)
filterCompressedLooByAppliedFilters(compressedLoo, appliedFilterTypes),
);

return parsedAndFilteredMarkers
Expand Down Expand Up @@ -222,18 +222,9 @@ const MarkerGroup: React.FC<{
.map((child) => child.getIcon().options?.toiletId)
.join(',');

let c = ' marker-cluster-';
if (childCount < 10) {
c += 'small';
} else if (childCount < 100) {
c += 'medium';
} else {
c += 'large';
}

return new L.DivIcon({
html: `<div data-toilets=${containedIds}><span>${childCount}</span></div>`,
className: 'marker-cluster' + c,
className: 'marker-cluster',
iconSize: new L.Point(40, 40),
});
},
Expand Down
13 changes: 13 additions & 0 deletions src/design-system/components/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@
@import 'src/design-system/components/Switch/Switch.css';
@import 'src/design-system/components/TextArea/TextArea.css';
@import 'src/design-system/components/Drawer/Drawer.css';

/* Leaflet Marker Cluster custom styles */
.leaflet-marker-icon.marker-cluster {
display: flex;
border: 0.25em solid #ED3D63;
background-color: white;
padding: 0.125em;
border-radius: 40px;
}
.leaflet-marker-icon.marker-cluster div {
margin: auto;
background-color: transparent;
}

0 comments on commit a1b4e94

Please sign in to comment.