Ah! If you're a geographer, you'll probably start learning more and more Leaflet as you go along. Amazing library.
In this case, the markers are just images which
Leaflet calls "Icons".
In the dc.js coding style, everything is a function which encodes attributes of the data with visual attributes. So we have the method markerChart.icon() which gets/sets an accessor or encoding function.
Actually the tricky part here is the crossfilter reduction. When you just use group.reduceCount() (the default), the only data that is available is key and value, where the value is an integer. So we have no data to color on available in the aggregation.
Since this is an important use-case, I've changed
the demo page to color the markers.
In that data, the field we want to color on is "type", which has values like "solar", "wind", etc. It's probably a different field for you.
The reduction looks like:
var facilitiesGroup = facilities.group().reduce(
function(p, v) {
p.type = v.type;
++p.count;
return p;
},
function(p, v) {
--p.count;
return p;
},
function() {
return {count: 0};
}
);
The difference between this and reduceCount is that instead of value being an integer, it's now an object with two fields, "type" and "count". We grab "type" from the first row we see (which only makes sense if there is only one row per bin, as is the case here). And we increment and decrement "count" when a row is added or removed.
Since the data format changed, we're going to need to tell the markerChart how to read a value, so that it can remove markers when they go to zero:
.valueAccessor(d => d.value.count)
And now here's the fun part, assigning icons. In a quick search, the top library for "leaflet marker color" is this one:
This is a nice simple solution because you don't have to install any plugins or anything. You just change the iconUrls based on the data, to point at the CDN for this library:
.icon(function(d) {
var iconUrl;
switch(d.value.type) {
case 'solar':
break;
case 'hydro':
break;
case 'wind':
break;
case 'biomass':
break;
case 'gas_waste':
break;
case 'hydro_waste':
break;
default:
console.log('unk', d.value.type);
return new L.Icon.Default();
}
return new L.Icon({
iconUrl: iconUrl,
});

I think there are more complex plugins which will allow changing the color dynamically, instead of just having certain colors. But I haven't looked at that today.
Hopefully this is enough to get you started!
Cheers,
Gordon