googlemaps / googlemaps/js-markerclusterer

feat(DefaultRenderer): custom color

Open
#870 0 comments 3 reactions 0 assignees View on GitHub
triage me type: feature request
Dominant language
TypeScript
Stars
293
Forks
104
Avg merge
3m
Merged PRs (30d)
18

Description

**Is your feature request related to a problem? Please describe.**
To avoid having the recreate the renderer just to be ab le to change the color, letting user change those color while instantiating the class would be useful

**Describe the solution you'd like**
Add two color variable that can be set through class instantiation.

**Additional context**
The Idea

```typescript
export class DefaultRenderer implements Renderer {
underMeanColor: string
overMeanColor: string

constructor(underMeanColor = '#0000ff', overMeanColor = '#ff0000') {
this.underMeanColor = underMeanColor
this.overMeanColor = overMeanColor
super()
}

public render( { count, position }: Cluster, stats: ClusterStats, map: google.maps.Map): Marker {
// change color if this cluster has more markers than the mean cluster
const color =
count > Math.max(10, stats.clusters.markers.mean) ? this.overMeanColor : this.underMeanColor;

// ...
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.