How to draw interior buffer or interior stroke on a polygon with OpenLayers 4

Viewed 573

I'd like to recreate the same style that OSM use when editing polygons. I'm calling it an 'interior stroke' or 'interior buffer'.

OSM example:

enter image description here

I know that I can use an array of ol.style.Style, with one sending back geometry for the interior buffer. However it seems really resource intensive to create new geometries simply to represent the original geometry with a buffer. Is that the recommended way? Can I use ol.style.Stroke in some advanced manner?


An additional feature is that the screen pixel width of the 'interior stroke' is a constant amount, irrespective of zoom level. For example, here's that polygon zoomed out and in:

Zoomed out Zoomed in

1 Answers
Related