I have ~ 100,000 functions displayed on the map. At a certain zoom level, I want to add a shortcut above the functions. Here's the untagged style:
style: function(feature, resolution) {
var style = [new ol.style.Style({
image: new ol.style.Icon({
src: myImg,
rotation: myRotation
})
})]};
I tried to create a function created to create a new style, to add a label
labelStyleFunction: function(name){
return new ol.style.Style({
text: new ol.style.Text({
text: name,
font: ' 10px Arial',
fill: new ol.style.Fill({
color: 'black'
}),
offsetY: -10,
offsetX: 30
})
});
}
And when I reached the desired level, I tried layer.forEachFeature and layer.forEachFeatureInExtent
if(zoom >= 15 && status){
me.getData('clusters100').getSource().getSource().forEachFeatureInExtent(extent,function(feature){
feature.setStyle([
me.labelStyleFunction(feature.get('name'))
]);
});
}
But both made my application crash, due to the huge number of functions that I think ... Therefore, I thought about opacity being 0 on the shortcut, then opacity 1 at 15, but:
- Is it possible?
- How can I achieve this?
So4ne source
share