Currently I am getting only a white dotted line in my map using the code below:
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color:[255, 255, 255, 1.0],
opacity: 1,
width: 4,
lineDash: [4, 4]
}),
fill: new ol.style.Stroke ({
color: [155, 155, 155, 0.4]
})
})
But my requirement is to get black and white dotted lines in the form black white black white…
Best Answer
You can set more than one style for a layer and overlay them
Go to http://openlayers.org/en/v4.6.5/examples/vector-layer.html, open the console and execute the following
To grasp dash pattern (for white lines), you can go to http://phrogz.net/tmp/canvas_dashed_line.html (link borrowed from answer Dashed lines in OL3?)
PS: contrary to @JGH other answer, I didn't bother with offset and instead choose to add dash lines on top of a continuous line. Both approaches are valid, just a question of preferences.