我想知道是否有可能从deck.gl层访问聚合数据,以便能够绘制图例。
因为提供了配色方案,所以我只需要屏幕格层计算的聚合值的范围就可以将其添加到图例中。
我知道有工具提示,但在某些情况下,能够访问这些值会很好。
发布于 2020-08-08 08:53:31
我使用的是HexagonLayer,在初始化层时,您可以使用半定制的onSetColorDomain函数来查找层的值。然后将域范围数组保存到一个变量中,并调用make legend函数。
例如:
const hexlayer = new HexagonLayer({
id: 'heatmap',
pickable: true,
colorRange: COLOR_RANGE,
data: feats_obj.coords_array,
elevationScale: 9,
extruded: true,
radius: 300,
getColorValue: points => {
if( points.length > max_points) {
max_points = points.length
}
renderCategories( incident_categories )
return points.length
},
onSetColorDomain: (ecol) => {
console.log('color domain set', ecol)
max_span.innerHTML = ecol[1]
color_domain = ecol;
create_legend()
// console.log('max_points: ', max_points)
},...
})我想的最好的方法是在初始化层的外部在一个多边形全局变量中设置一个最大点数,当有一个多边形中的点数超过这个最大值时,让它随时更新这个值。在野外的一个例子是:https://mpmckenna8.github.io/sfviz/?start_date=2020-05-01&end_date=2020-05-31,它有一个指向你可以黑进去的仓库的链接。
https://stackoverflow.com/questions/62030823
复制相似问题