1

My question is similar but slightly different to: https://stackoverflow.com/questions/5003349/openlayers-vector-features-z-indexing

I have an OpenLayers Vector layer which contains polygons and points from PostGIS. I do not want to create a separate table for each entity. I have a StyleMap set for the layer and have zIndexing set to true. My points are using an external graphic and my polygons just a normal style.

Problem: I cannot get the external graphic to render above the the polygons. If I used a normal point then it does render above the polygons. I believe I've tried all combinations of graphicZIndex and zIndex for the point and polygon layers.

Layer def:

        var lyrJamoats = new OpenLayers.Layer.Vector("Jamoats", {
                strategies : [new OpenLayers.Strategy.Fixed()],
                styleMap : Styles.styleJamoat,
                rendererOptions : {
                    zIndexing : true
                },
                protocol: {protocol stuff}
    });

Style def:

styleJamoat : new OpenLayers.StyleMap({
    "default" : new OpenLayers.Style(null, {
        rules : [new OpenLayers.Rule({
            symbolizer : {
                "Point" : {
                    fillColor : "#ffcc66",
                    strokeColor : "#ff9933",
                    strokeWidth : 2,
                    graphicZIndex : 1000,
                    //zIndex: 99999999,
                    externalGraphic : "./img/jamoat_pin.png",
                    pointRadius : 30
                },
                "Polygon" : {
                    strokeWidth : 2,
                    strokeOpacity : 1,
                    strokeColor : "#FFFFFF",
                    fillColor : "#002776",
                    fillOpacity : 0.75,
                    zIndex: 0
                    //graphicZIndex: 0,
                }
            }
        })]
    }),
1

This seemed to work. I deleted everything from my PostGIS table then inserted the points before the polygons. I then included zIndex and graphicZIndex properties for the point and polygon style rules. Also added both style rules to the "select" rule as I suspect the hover tool I'm using is interfering with play.

styleJamoat : new OpenLayers.StyleMap({
    "default" : new OpenLayers.Style(null, {
        rules : [new OpenLayers.Rule({
            symbolizer : {
                "Point" : {
                    fillColor : "#ffcc66",
                    strokeColor : "#ff9933",
                    strokeWidth : 2,
                    graphicZIndex : 9999999,
                    zIndex: 99999999,
                    externalGraphic : "./img/jamoat_pin.png",
                    pointRadius : 15,
                    fillOpacity : 1,
                },
                "Polygon" : {
                    strokeWidth : 2,
                    strokeOpacity : 1,
                    strokeColor : "#FFFFFF",
                    fillColor : "#002776",
                    fillOpacity : 0.75,
                    zIndex: 1,
                    graphicZIndex: 1,
                }
            }
        })]
    }),
    "select" : new OpenLayers.Style(null, {
        rules : [new OpenLayers.Rule({
            symbolizer : {
                "Point" : {
                    fillColor : "#ffcc66",
                    strokeColor : "#ff9933",
                    strokeWidth : 2,
                    graphicZIndex : 1000,
                    //zIndex: 99999999,
                    externalGraphic : "./img/jamoat_pin_sel.png",
                    pointRadius : 15,
                    fillOpacity : 1,
                },
                "Polygon" : {
                    strokeWidth : 2,
                    strokeOpacity : 1,
                    strokeColor : "#FFFFFF",
                    fillColor : "#12D400",
                    fillOpacity : 0.75
                }
            }
        })]
    })
}),  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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