var features = [
new ol.Feature({
\t geometry: new ol.geom.Point([0,0])
}),
new ol.Feature({
\t geometry: new ol.geom.Point([100000,500000])
}),
new ol.Feature({
\t geometry: new ol.geom.Point([500000,100000])
}),
new ol.Feature({
\t geometry: new ol.geom.Point([5000000,1000000])
}),
new ol.Feature({
\t geometry: new ol.geom.Point([1000000,500000])
})
/*,new ol.Feature({
\t geometry: new ol.geom.Point([1800000,800000])
})*/
\t ],
source = new ol.source.Vector({
\t features: features
});
var layer;
if (features.length > 5) {
var clusterSource = new ol.source.Cluster({
distance: parseInt(40, 10),
source: source
});
var styleCache = {};
layer = new ol.layer.Vector({
source: clusterSource,
style: function(feature) {
var size = feature.get('features').length;
var style = styleCache[size];
if (!style) {
style = new ol.style.Style({
image: new ol.style.Circle({
radius: 10,
stroke: new ol.style.Stroke({
color: '#AAA'
}),
fill: new ol.style.Fill({
color: '#DDD'
})
}),
text: new ol.style.Text({
text: size.toString(),
fill: new ol.style.Fill({
color: '#B144FF'
})
})
});
styleCache[size] = style;
}
return style;
}
});
} else {
layer = new ol.layer.Vector({
source: source
});
}
var map = new ol.Map({
layers: [
\t new ol.layer.Tile({
\t \t source: new ol.source.OSM()
\t \t }),
layer
],
target: 'clusterMap',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
<link href="https://openlayers.org/en/v3.20.1/css/ol.css" rel="stylesheet"/>
<script src="https://openlayers.org/en/v3.20.1/build/ol.js"></script>
<div id="clusterMap" class="map"></div>
可能なソリューションのためのhttp://viglino.github.io/OL3-AnimatedCluster/を見てください。 –
私はあなたがそれぞれのジオメトリを持つスタイルの配列を返さなければならないかもしれないと思う。 –