Q:

OpenLayers draw line string with line width in meters

Want to draw Line string with line width measured in meters 
Tried styles but they are fixed width(in pixels) and don't change line thickness while zooming
Thanks in advance 

A:

If anybody is interested:
function() {
    return [
        new ol.style.Style({
            stroke: new ol.style.Stroke({
                color: 'rgba(0,0,0,1)',
                width: 50 / ol.map.getView().getResolution()
            })
        })
    ]
}

You can provide a function which returns a ol.style.Style instead of using a ol.style.Style directly (e.g. with setStyle).
This function is called within every single render process and you can change the width of a ol.style.Stroke dynamically.
In the case above a line is drawn, where the width should represent 50 meters in the real world if you use the Web Mercator projection (EPSG:3857).

