Если вы проверяете только первую функцию в каждом кластере:
function myStyleFunction(feature) {
let props = feature.get('features')[0].getProperties();
if (props.id>50) {
console.log(props.id);
return new ol.style.Style({image: style1,stroke: new ol.style.Stroke({ color:"#fff", width:1 }) });
} else {
console.log(props.id);
return new ol.style.Style({image: style2,stroke: new ol.style.Stroke({ color:"#fff", width:1 }) });
}
};
Если вы хотите найти значение в любой функции в кластере
function myStyleFunction(feature) {
let maxId = 0;
feature.get('features').forEach(function(feature){
maxId = Math.max(maxId, feature.getProperties().id);
});
if (maxId>50) {
console.log(maxId);
return new ol.style.Style({image: style1,stroke: new ol.style.Stroke({ color:"#fff", width:1 }) });
} else {
console.log(maxId);
return new ol.style.Style({image: style2,stroke: new ol.style.Stroke({ color:"#fff", width:1 }) });
}
};
Для ol-extкластер
function myStyleFunction(feature) {
let id = 0;
let features = feature.get('features');
if (features) {
id = features[0].get('id');
}
if (id > 50) {
return new ol.style.Style({image: style1,stroke: new ol.style.Stroke({ color:"#fff", width:1 }) });
} else {
return new ol.style.Style({image: style2,stroke: new ol.style.Stroke({ color:"#fff", width:1 }) });
}
};