Dynamic coloring of map markers


I am adding assets to a map. Each of these assets may belong to a group, and if they are part of the same group then I want them to be the same colour. I don’t know the group names ahead of time, so I need to be able to generate these colours to denote the groupings at runtime.

How can I do this so that:

  1. the colors are the same for each group name, and
  2. the generated colors will be evenly distributed across the color spectrum?
  3. (bonus question) How could I use colors from a pre-defined (static) list?

Note: The current implementation is along the lines of the below. Its deficiency is that it doesn’t necessarily produce contrasting colors.

entity type SomeAsset {
	id: string
	colorValue: int stored calc "md5HashKey(id)”

component SomeAssetMap {
	“component”: “Map”,
	"markerColors": {
            "field": “someAsset.colorValue",
            "colorRange": ["000000", "ffffff"],
            "valueRange": [0, 268435455]