Skip to content
Advertisement

Different layer styles affecting each other openlayers

I want to draw dashed line and straight line by using open layers Draw method. In this method there is a LineString option for drawing straight line but I cound not find a option for dashed line. So my aim is to style LineString and make a dashed line. But the problem is, this approach is also affecting the straight line style even though I’m keeping them in different layers.

JavaScript

LineString and lineDashed are input radio. Whenever user select one of this input type I want them to be able to draw that option. But the above code problem is when I select lineDash it is also yellow just like lineString. And if I select lineDash and then select lineString again this time lineString have a dash style on it. This issue is also affecting the lines already on the map.

Advertisement

Answer

You need to remove the old interaction before creating and adding a new one

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement