//cyd
var cydclusterSource = new ol.source.Cluster({
distance: 40,
source: new ol.source.Vector({
features:(new ol.format.GeoJSON()).readFeatures(JSON.stringify(cyd))
})
});
//sc
var scclusterSource = new ol.source.Cluster({
distance: 40,
source: new ol.source.Vector({
features:(new ol.format.GeoJSON()).readFeatures(JSON.stringify(sc))
})
});
//sy
var syclusterSource = new ol.source.Cluster({
distance: 40,
source: new ol.source.Vector({
features:(new ol.format.GeoJSON()).readFeatures(JSON.stringify(sy))
})
});
//xq
var xqclusterSource = new ol.source.Cluster({
distance: 40,
source: new ol.source.Vector({
features:(new ol.format.GeoJSON()).readFeatures(JSON.stringify(xq))
})
});
var cydstyleCache = {};
this.cydVectorLayer = new ol.layer.Vector({
source:cydclusterSource,
style:function(feature) {
var size = feature.get('features').length;
var style = cydstyleCache[size];
if (!style) {
style = new ol.style.Style({
image: new ol.style.Circle({
radius: 20,
stroke: new ol.style.Stroke({
color: '#fff'
}),
fill: new ol.style.Fill({
color: '#3399CC'
})
}),
text: new ol.style.Text({
text: "cyd "+size.toString(),
fill: new ol.style.Fill({
color: '#fff'
})
})
});
cydstyleCache[size] = style;
}
return style;
}
});
https://blog.csdn.net/zy13608089849/article/details/70809354