Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a custom cluster marker style #1664

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading