GWT OpenLayers在聚类点上设置基础VectorFeatures的值之和

Moonsera

我正在使用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( ??? ); 
Moonsera

在将策略分配给VectorLayer的方法中:

{
    org.gwtopenmaps.openlayers.client.Style style = new org.gwtopenmaps.openlayers.client.Style();
    style.setJSObject(getOpenLayersStyle());
}

魔术在哪里完成:

private native JSObject getOpenLayersStyle() /*-{
    var style = new $wnd.OpenLayers.Style({
        fontColor: "#FFFFFF",
        fontSize: "12px",
        label: "${countLabel}"
        }, { context: {
            countLabel: function(feature) {
                var countLabel;
                if (feature.cluster) {
                    var result_count = 0;
                    for (var i = 0; i < feature.cluster.length; i++) {
                        result_count += feature.cluster[i].attributes.result_count;
                    }
                    countLabel = result_count.toString();
                } else {
                    countLabel = feature.attributes.result_count.toString();
                }
                feature.attributes.label = countLabel;
                return countLabel;
            }
        }
    });
    return style;
}-*/;

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

GWT openlayers,DrawFeature线型

来自分类Dev

调试GWT生成的类

来自分类Dev

使用GWT设置Cookie

来自分类Dev

如何调用 GWT 模块入口点类?

来自分类Dev

从JSNI类创建GWT jar

来自分类Dev

GWT:检索生成的类名

来自分类Dev

GWT JsInterop本机类问题

来自分类Dev

TextBox上的GWT输入事件

来自分类Dev

GWT 代码卡在 reactToMessages 上

来自分类Dev

将OpenSeaMap集成到GWT OpenLayers中

来自分类Dev

Google图层似乎与gwt-openlayers错误

来自分类Dev

设置最小和最大zoomLevels(GWT-OpenLayers)

来自分类Dev

如何使用GWT模拟Java类

来自分类Dev

不混淆GWT HTML类标记样式

来自分类Dev

GWT / UiBinder中的Ui:style或CSS类

来自分类Dev

使用-generateJsInteropExports控制GWT包括哪些类

来自分类Dev

CSS,GWT和读取组成的类名

来自分类Dev

在GWT / Bootstrap中设置数据属性

来自分类Dev

GWT Datepicker设置打开时的默认日期

来自分类Dev

GWT材质-设置下拉选择文本

来自分类Dev

gwt setEnabled不在GoogleChrome上执行

来自分类Dev

动态静态Asyncallback上的逻辑问题-GWT

来自分类Dev

在Eclipse上运行GWT时出错

来自分类Dev

GWT CellTable 排序 - 如何使用排序值?

来自分类Dev

错误:编译GWT项目时找不到或加载主类com.google.gwt.dev.Compiler

来自分类Dev

错误:编译GWT项目时找不到或加载主类com.google.gwt.dev.Compiler

来自分类Dev

GWT和CSRF Guard-是否可以在GWT代码上实现CSRF Guard?

来自分类Dev

如何使用gwt-openlayers添加WMS图层?

来自分类Dev

未加载GWT Maven应用程序入口点