Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a newbie in OpenLayers. Can you help me with this:

Is it possible to assign color not to the whole linestring, but to different segments?

share|improve this question
i think it is not possible. but you can separate them different segments for defining new colors to all segments... vectorLayer.features[x].geometry.components will give you to all segments... – Aragon Aug 9 '12 at 8:53

Bad news: it's not possible. You will have to break up your lines and assign different styles to each of them as suggested by @Aragon.

share|improve this answer

All GIS tools treat a set of connected nodes do not having same start and end nodes as a single linestring unless you break it explicitly as mentioned by @unicoletti. And openlayers is not an expecption in this case. ofcourse you can do it using some code to break up every node and visualize on web or whatever.

But this creates problem and GIS tools will not consider it as a single valid linestring. Only a big answer is to hack into OL code and consider each line as a set of two nodes which are drawn individually. or create a different layer with you line broken into set of two nodes.

Hope this helps

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.