传单层 Z-index [英] Leaflet layers Z-index

查看:24
本文介绍了传单层 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 中可行吗?

推荐答案

可以,但不使用 bringToFrontbringToBack.您需要在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆