The style property of a Vector layer accepts an array of values in addition to a single value, so you can create two dashed strokes using lineDash
and give them different lineDashOffset
values;
var lightStroke = new ol.style.Style({
stroke: new ol.style.Stroke({
color: [255, 255, 255, 0.6],
width: 2,
lineDash: [4,8],
lineDashOffset: 6
})
});
var darkStroke = new ol.style.Style({
stroke: new ol.style.Stroke({
color: [0, 0, 0, 0.6],
width: 2,
lineDash: [4,8]
})
});
Then apply them to the same layer like this;
var myVectorLayer = new ol.layer.Vector({
source: myPolygon,
style: [lightStroke, darkStroke]
});