OpenLayers,不错的标记聚类

新手上路,请多包涵

你知道如何在 OpenLayers 中有一个很好的集群,比如这个 谷歌示例 吗?

原文由 apneadiving 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 404
2 个回答

您可以在上面的示例中将标签添加到 pointStyle 并解释此标签的上下文。你的代码应该是这样的:

 var pointStyle = new OpenLayers.Style({
    // ...
    'label': "${label}",
    // ...
  }, {
    context: {
      // ...
      label: function(feature) {
        // clustered features count or blank if feature is not a cluster
        return feature.cluster ? feature.cluster.length : "";
      }
      // ..
    }
});

var styleMap = new OpenLayers.StyleMap({
  'default': pointStyle,
});

var googleLikeLayer = new OpenLayers.Layer.Vector("GoogleLikeLayer", {
  // ...
  styleMap  : styleMap,
  // ...
});

原文由 unibasil 发布,翻译遵循 CC BY-SA 3.0 许可协议

推荐问题