I need help concerning feature clustering in OpenLayers 3. I have a vector layer that dynamically "collects" a large number of features. All features have various properties like title, content, permalink.
Unfortunately, I only have a clue how to copy style data from the source layer (for all features that are not included into clustering at the respective zoom level).
How do I get all the other properties into the features at the cluster layer?
I would like to add feature.get('permalink') and so on, but I don't have any idea where I have to put this.
Here's my code:
// marker clustering
clusterLayer[i] = new ol.layer.Vector({
source: clusterSource[i],
style: function(feature) {
var size = feature.get('features').length;
if(size > 1) {
var style = new ol.style.Style({
image: new ol.style.Circle({
radius: 10,
stroke: new ol.style.Stroke({
color: '#fff'
}),
fill: new ol.style.Fill({
color: '#3399CC'
})
}),
text: new ol.style.Text({
text: size.toString(),
fill: new ol.style.Fill({
color: '#fff'
})
})
});
}
else var style = feature.get('features')[0].getStyle();
return style;
}
});
Any idea how I can add the properties from all source layer features to the features at the cluster layer?
Best Answer
Here is a code snip to help you out:
An here is a fiddle to see it in action