Skip to content Skip to sidebar Skip to footer

Openlayers 3 Image And Text Style Zindex

I've noticed that text and image styles don't seem to respect their layer order when being rendered. For example, when many features with these styles are close together, all the t

Solution 1:

When stacking point symbols with text, you need to give every point its own (increasing) zIndex if you want the text to stick to the symbol. See http://jsfiddle.net/8g1vayvc/. You can also do that in a style function:

var myStyle = new ol.style.Style({/*...*/});
var zIndex = 0;
function styleFunction(feature, resolution) {
  myStyle.setZIndex(zIndex++);
  return myStyle;
}

Post a Comment for "Openlayers 3 Image And Text Style Zindex"