From 7cbf350b732b9e8780faaa44bcddda2f1f411250 Mon Sep 17 00:00:00 2001 From: Arik Fraimovich Date: Sat, 8 Oct 2016 11:59:19 +0300 Subject: [PATCH] Use group color for the marker-cluster --- rd_ui/app/scripts/visualizations/map.js | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/rd_ui/app/scripts/visualizations/map.js b/rd_ui/app/scripts/visualizations/map.js index 4be75b22c..bbb07b8b3 100644 --- a/rd_ui/app/scripts/visualizations/map.js +++ b/rd_ui/app/scripts/visualizations/map.js @@ -127,7 +127,32 @@ var markers; if ($scope.visualization.options.clusterMarkers) { - markers = L.markerClusterGroup(); + var color = $scope.visualization.options.groups[name].color; + var options = {}; + + if (classify) { + options.iconCreateFunction = function (cluster) { + var childCount = cluster.getChildCount(); + + var c = ' marker-cluster-'; + if (childCount < 10) { + c += 'small'; + } else if (childCount < 100) { + c += 'medium'; + } else { + c += 'large'; + } + + c = ''; + + + var style = 'color: white; background-color: '+color+';'; + + return L.divIcon({ html: '
' + childCount + '
', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) }); + } + } + + markers = L.markerClusterGroup(options); } else { markers = L.layerGroup(); }