我正在使用gwt-openlayers-1.0
,目前正在学习这个例子(动画集群策略)。
在我的项目中,每个VectoreFeature
都有一个数字标签,我想显示每个聚类点上基础点的标签值总和。有没有办法做到这一点?
upd:
根据这篇JS 中的文章(“最重要”策略部分),它看起来像这样:
// for each feature:
feature.attributes = { result_count: 10 };
...
var style = new OpenLayers.Style({
...
} , context: {
label: function(feature) {
if (feature.cluster) {
var result_count = 0;
for (var i = 0; i < feature.cluster.length; i++) {
result_count += feature.cluster[i].attributes.result_count;
}
features.attributes.label = result_count.toString();
} else {
features.attributes.label = features.attributes.result_count.toString();
}
}
}
但我找不到在 gwt-openlayers 中实现这一点的方法:
org.gwtopenmaps.openlayers.client.Style style = new org.gwtopenmaps.openlayers.client.Style();
style.setLabel( ??? );