Skip to content

Instantly share code, notes, and snippets.

@harllos
Created March 15, 2019 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harllos/73669fbbb605854978193ae13f28ee5d to your computer and use it in GitHub Desktop.
Save harllos/73669fbbb605854978193ae13f28ee5d to your computer and use it in GitHub Desktop.
var colorStops, radiusStops;
function updateClusters(repaint) {
 currentZoom = map.getZoom();
 clusterData = turf.featureCollection(cluster.getClusters(worldBounds, Math.floor(currentZoom)))
let stops_domain = chroma.limits(getFeatureDomain(clusterData, select_value), 'e', 8)
 //coloração original era definida pela linha abaixo. copiei, colei e utilizei escala logarítimica que tirei daqui: https://github.com/gka/chroma.js/
 var scale = chroma.scale(color).domain(stops_domain).mode('lab')
 colorStops = createColorStops(stops_domain, scale)
 radiusStops = createRadiusStops(stops_domain, 20, 50);
if (repaint) {
 map.setPaintProperty('clusters', 'circle-color', {
 property: select_value,
 stops: colorStops
 });
map.setPaintProperty('clusters', 'circle-radius', {
 property: select_value,
 stops: radiusStops
 });
map.setPaintProperty('unclustered-point', 'circle-color', {
 property: propertyToAggregate,
 stops: colorStops
 });
map.setLayoutProperty('cluster-count', "text-field", "{" + select_value + "}");
 }
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment