79627967

Date: 2025-05-19 01:31:19
Score: 1
Natty:
Report link

I should have read the docs more closely. Style has a zIndex property itself.

All I had to do was add the zIndex property to my two Style objects, giving a higher zIndex to my selected style and it now renders the selected-style features on top of the normal-styled features:

export const normalAOIStyle = new Style({
    stroke: new Stroke({
        color: '#004C73',
        width: 1,
    }),
    fill: new Fill({
        color: 'rgba(255, 255, 255, 0)',
    }),
    // The current zIndex on my VectorTileLayer overall is set to 2, 
    // so I set 2 here as well
    zIndex: 2 
})

export const selectedAOIStyle = new Style({
    stroke: new Stroke({
        color: 'rgb(10, 250, 242, 1)',
        width: 2,
    }),
    fill: new Fill({
        color: 'rgba(10, 250, 242, 0.1)',
    }),
    // I want selected feature styles to sit "on top" of normal feature styles
    // so I gave this Style a higher zIndex number
    zIndex: 3
})
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: MKF