Malte
Malte

Reputation: 53

OpenLayers: Mix sorting for layers and features

We use a bunch of different layers from different sources with OpenLayers 6.5. One of these layers is a MVT layer, containing a dozen different features. I am able to setup an individual style for each of these features and I can sort them within the mvt layer as well:

     const style = new Style({
        fill: new Fill({
            color: hexToRGB(layerData.layerColorFill, layerData.layerOpacity),
        }),
        stroke: new Stroke({
            color: hexToRGB(layerData.layerColorStroke, layerData.layerOpacity),
            width: layerData.layerStrokeWidth,
        }),
        zIndex: -layerData.layerOrder,
    });

Is it somehow possible to move one of these features out of the MVT layer behind another ZXY layer? It looks like the zIndex property only applies to all features within a layer, but not through the whole map.

Upvotes: 0

Views: 301

Answers (1)

Mike
Mike

Reputation: 17932

You will need two MVT layers sharing the same source. Here https://codesandbox.io/s/vector-tile-info-forked-g9d08 the country names are seen through the semi opaque XYZ layer while city names are above it, Specify a unique layer className otherwise decluttered items will be rendered together above all other layers.

Upvotes: 0

Related Questions