I have a vector layer with the style currently defined as:
var styles = new ol.style.Style({
image: new ol.style.Circle({
radius: 4,
fill: new ol.style.Fill({color: 'red'}),
stroke: new ol.style.Stroke({color: 'black', width: 1})
})
I want the radius to change dynamically, based on the map zoom level - something like:
radius:(zoom/2)+1
How would I go about doing so?
UPDATE: Jonatas' comment helped steer me in the right direction. I ended up using the following:
map.getView().on('change:resolution', function(evt) {
var zoom = map.getView().getZoom();
var radius = zoom / 2 + 1;
var newStyle = new ol.style.Style({
image: new ol.style.Circle({
radius: radius,
fill: new ol.style.Fill({color: 'red'}),
stroke: new ol.style.Stroke({color: 'black', width: 1})
})
})
vectorLayer.setStyle(newStyle);
});