美文网首页
openlayer中zindex设置

openlayer中zindex设置

作者: 辰宇26 | 来源:发表于2019-08-15 09:18 被阅读0次

    openlayer中zindex设置

    在地图开发过程中,遇到多个图标相互覆盖问题,这时可以使用zIndex控制图标的层级显示。

    var iconStyle = new ol.style.Style({
        image : new ol.style.Icon({ ... }),
        zIndex : 1
    });
    
    var feature = new ol.Feature({
        geometry: format.readGeometry(geoWktStr, {
            dataProjection: 'EPSG:4326',
            featureProjection: ...
        }),
        styles: iconStyle,
        ...
    });
    
    var sourceVector =  new ol.source.Vector();
    sourceVector.addFeature(feature);
    
    var vectorLayer = new ol.layer.Vector({
        source: sourceVector,
        opacity: 1,
        zIndex: 2
    });
    

    zIndex for style: 控制图层的渲染顺序,图层渲染时,按照zIndex进行排序。

    zIndex for layer: css样式中的zIndex。

    相关文章

      网友评论

          本文标题:openlayer中zindex设置

          本文链接:https://www.haomeiwen.com/subject/inrajctx.html