I want to set the rotation of an ol.style.Icon
to a given feature property. See line 12 of this:
var styleCache_airports={}
var style_airports = function(feature, resolution){
var value = ""
var size = 0;
var style = [ new ol.style.Style({
image: new ol.style.Icon({
imgSize: [32, 32],
scale: 0.59375,
anchor: [9, 9],
anchorXUnits: "pixels",
anchorYUnits: "pixels",
rotation: function(feature){return feature.get("ELEV") * 0.0174533;},
src: "styles/a18_sluis.svg"
})
})];
if ("" !== null && resolution > 28 && resolution < 1400) {
var labelText = String("");
} else {
var labelText = ""
}
var key = value + "_" + labelText
if (!styleCache_airports[key]){
var text = new ol.style.Text({
font: '10.725px \'MS Shell Dlg 2\', sans-serif',
text: labelText,
textBaseline: "center",
textAlign: "left",
offsetX: 5,
offsetY: 3,
fill: new ol.style.Fill({
color: "rgba(0, 0, 0, 255)"
}),
});
styleCache_airports[key] = new ol.style.Style({"text": text})
}
var allStyles = [styleCache_airports[key]];
allStyles.push.apply(allStyles, style);
return allStyles;
};
This doesn't work, and doesn't throw any errors. If I replace it with a static value, it works. What am I doing wrong?