Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm using GeoServer, OpenLayers and WFS features. For one layer, I managed to set either rules to display according to a field or SelectFeature with a styleMap to highlight features when the mouse is over.

I would like to combine both, that's to say display features according to its rules but also being able to highlight features when the mouse is over.

Is that possible?

share|improve this question

2 Answers 2

Definitely possible. See this example:

 var myStyles = new OpenLayers.StyleMap({
            "default": new OpenLayers.Style({
                pointRadius: "${type}", // sized according to type attribute
                fillColor: "#ffcc66",
                strokeColor: "#ff9933",
                strokeWidth: 2,
                graphicZIndex: 1
            "select": new OpenLayers.Style({
                fillColor: "#66ccff",
                strokeColor: "#3399ff",
                graphicZIndex: 2

Single stylemap includes multiple styles

And here are the different intents that StyleMap supports

share|improve this answer
Thanks for your answer. I don't know if it is because I don't understand or because I was not precise in my question, as I don't see how to use Openlayer.Rule to define a rule and then add it to the stylemap like stylemap.addrules. On one side, I find stylemap,to highlight or symbolize according to value and on the other style and addrules to use openlayers.filters.comparison. I don't find stylemap.addrules – Olivier Mar 24 '12 at 7:50
I found but added point to thank you for your answer. – Olivier Mar 24 '12 at 18:18
up vote 0 down vote accepted

I found. Here is an example add lines 80-112, removing the two "if".

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.