添加图层时默认将图层放在所有图层的最上面,那么如何在任意位置插入图层呢?

根据api,我们可以利用下图所示的两个接口:getLayers与collection的insertAt。具体代码见下。

openlayers 图层顺序;在任意位置叠加图层

openlayers 图层顺序;在任意位置叠加图层 

var ImageVector = new ol.layer.Tile({ 
                source:new ol.source.XYZ({
                    url:'地图地址',
                    tileSize:256
                }),
                visible:false,
                name:'visibleTile'
            });

var layersArray = map.getLayers();
layersArray.insertAt(1,ImageVector);

 

相关文章:

  • 2021-09-28
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2021-11-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-12-19
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案