OpenLayers,很好的标记聚类 [英] OpenLayers, nice marker clustering
本文介绍了OpenLayers,很好的标记聚类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Do you know how to have a nice clustering in OpenLayers such as this google example ?
推荐答案
您可以在上面的示例中将标签添加到pointStyle并解释该标签的上下文. 您的代码应如下所示:
You can add label to pointStyle in above example and explain context of this label. Your code should be something like this:
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,
// ...
});
这篇关于OpenLayers,很好的标记聚类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文