小叶层Z索引 [英] Leaflet layers Z-index

查看:85
本文介绍了小叶层Z索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在小叶图层之间设置z-index(控制前景中的内容).

I need to set z-index (control what is in foreground) between leaflet layers.

例如可以通过BringToFront,brakeToBack函数在2个(或更多)geoJson图层之间或2个(或更多)ImageOverlay图层之间进行控制.

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上的这篇文章

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索引.

Of course, you can also place GeoJSON layers in their own pane(s) and manipulate their z-indexing as well.

这篇关于小叶层Z索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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