Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  17] [ 5]  / answers: 1 / hits: 30037  / 13 Years ago, sun, july 10, 2011, 12:00:00

Do you know how to have a nice clustering in OpenLayers such as this google example ?


More From » openlayers

 Answers
11

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,
// ...
});

[#91268] Friday, July 8, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hailie

Total Points: 25
Total Questions: 112
Total Answers: 111

Location: Belize
Member since Tue, Dec 8, 2020
4 Years ago
;