[OpenLayers-Dev] Hover style not working on GML

Dejung Gewissler dejung.gewissler at oit.state.nj.us
Fri Jan 11 11:15:52 EST 2008

Hi All-

I've added a GML layer to the map would like the following scenario:
    1) features rendered differently based on feature values (done with 
styles and rules)
    2) on mouseover/hover of a feature the hover styles to take effect
    3) on click of the feature a popup should appear

1) is done. 2) I can't get to work unless I attach a selectFeature 
control to the layer and set {hover: true}. Is there a way to accomplish 
this task without using the selectFeature control? The reason why is 
that I would like to use the selectFeature control in 3) and attach some 
functionality to the onSelect callback. In addition when I set {hover: 
true} on the selectFeature control the hover styles are not being 
honored. They default to blue for both stroke and fill.

I am currently implementing the following:

        var styleHash = 
        var styleRR = new OpenLayers.Style(styleHash);

        var rulePopGreat = new OpenLayers.Rule.Comparison({
            type: OpenLayers.Rule.Comparison.GREATER_THAN,
            property: "POP2000",
            value: "500000",
            symbolizer: {"Polygon": {fillColor: "#FF0000", strokeColor: 
"#00FF00", "hoverStrokeColor": "#00FF00", "hoverFillColor": "white"}}});
        var rulePopLess = new OpenLayers.Rule.Comparison({
            type: OpenLayers.Rule.Comparison.LESS_THAN,
            property: "POP2000",
            value: "200000",
            symbolizer: {"Polygon": {fillColor: "#0000FF", strokeColor: 
"#000000", "hoverStrokeColor": "#000000", "hoverFillColor": "white"}}});

            styleRR.addRules([rulePopGreat, rulePopLess]);

            myGML = new OpenLayers.Layer.GML("GML", 
"GML_County_Simplify.xml", {visibility:false, maxResolution:5000, style: 

Thanks ,

Dejung Gewissler
New Jersey Office of Information Technology
Office of Geographic Information Systems
200 Riverview Plaza
PO Box 212, Trenton, NJ 08625-0212


More information about the Dev mailing list