传单层 Z-index [英] Leaflet layers Z-index
问题描述
我需要在传单层之间设置 z-index(控制前景中的内容).
I need to set z-index (control what is in foreground) between leaflet layers.
有可能,例如在 2 个(或更多)geoJson 层之间或在 2 个(或更多)ImageOverlay 层之间进行控制,具有bringToFront、bringToBack 功能.
It is possible to e.g. control between 2 (or more) geoJson layers or between 2 (or more) ImageOverlay layers, with bringToFront, bringToBack functions.
L.geoJson 层总是在 L.imageOverlay 层之上,我需要将 imageOverlay 设置在 GeojJson 之上.
L.geoJson layer is always over L.imageOverlay layer and I need to set imageOverlay to be over GeojJson.
这在 Leaflet 中可行吗?
推荐答案
可以,但不使用 bringToFront
和 bringToBack
.您需要在 1.0.0 版本中使用自定义窗格.请参阅 GIS.SE 上的 这篇文章 和 本教程 在 Leaflet 网站上.总而言之,您需要为图像叠加创建一个新窗格,设置其 z-index,然后在创建图层时设置 pane
选项.以下将在您的 GeoJSON 图层上方添加图像叠加层:
Yes, but not using bringToFront
and bringToBack
. You need to use custom panes in the 1.0.0 version. See this post on GIS.SE and this tutorial on the Leaflet site. To summarize, you need to create a new pane for your image overlay, set its z-index, and then set the pane
option when you create the layer. The following will add an image overlay above your GeoJSON layers:
map.createPane('imagePane');
map.getPane('imagePane').style.zIndex = 401;
var imageLayer = L.imageOverlay(imageUrl, imageBounds, {
pane: 'imagePane'
}).addTo(map);
当然,您也可以将 GeoJSON 图层放置在它们自己的窗格中并操作它们的 z-indexing.
Of course, you can also place GeoJSON layers in their own pane(s) and manipulate their z-indexing as well.
这篇关于传单层 Z-index的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!