Created
March 15, 2019 00:09
-
-
Save harllos/73669fbbb605854978193ae13f28ee5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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