diff --git a/src/pages/Maps/Content/MapView/Sprites.tsx b/src/pages/Maps/Content/MapView/Sprites.tsx
index 0c76f7fa59..8af613ee95 100644
--- a/src/pages/Maps/Content/MapView/Sprites.tsx
+++ b/src/pages/Maps/Content/MapView/Sprites.tsx
@@ -1,9 +1,11 @@
+import { useEffect } from 'react'
import L from 'leaflet'
import { IModerationStatus } from 'oa-shared'
import clusterIcon from 'src/assets/icons/map-cluster.svg'
import AwaitingModerationHighlight from 'src/assets/icons/map-unpproved-pin.svg'
import { logger } from 'src/logger'
import Workspace from 'src/pages/User/workspace/Workspace'
+import { useThemeUI } from 'theme-ui'
import type { MarkerCluster } from 'leaflet'
import type { IMapPin } from 'oa-shared'
@@ -16,19 +18,54 @@ import './sprites.css'
* such as total pins. Currently none used, but retaining
*/
export const createClusterIcon = () => {
+ const { theme } = useThemeUI() as any
+ const path = clusterIcon
+ let iconAsString: string = ''
+ useEffect(() => {
+ fetch(path)
+ .then((response) => response.text())
+ .then((data) => {
+ iconAsString = data.replaceAll(
+ /#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})/g,
+ theme.colors.accent.base,
+ )
+ })
+ .catch((fetchError) => console.error(fetchError))
+ }, [path, theme])
return (cluster: MarkerCluster) => {
const className = ['icon']
let icon: any
- if (cluster.getChildCount() > 1) {
+ let outlineSize: number = 0
+ const clusterChildCount: number = cluster.getChildCount()
+ if (clusterChildCount > 1) {
className.push('icon-cluster-many')
- icon = clusterIcon
- } else if (cluster.getChildCount() === 1) {
- icon = cluster[0].pinType.icon
+ icon = iconAsString
+ // Calcute Outline CSS
+ if (clusterChildCount > 49) {
+ outlineSize = 24
+ } else {
+ outlineSize = 4 + ((clusterChildCount - 2) / 50) * 20
+ }
+ } else if (clusterChildCount === 1) {
+ icon = `${cluster.getChildCount()}`,
+ html: `${icon}${clusterChildCount}`,
className: className.join(' '),
iconSize: L.point(iconSize, iconSize, true),
})