leaflet.js中的图层排序 [英] Layer Ordering in leaflet.js

查看:467
本文介绍了leaflet.js中的图层排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何强制在Leaflet中添加到地图的新图层成为底图上的第一层?

How can I force a new layer added to the map in Leaflet to be the first over the basemap?

我找不到一种可以轻松更改图层顺序的方法,这是GIS的一项非常基本的功能.我想念什么吗?

I could not find a method to easily change the order of the layers, which is a very basic GIS feature. Am I missing something?

推荐答案

Leaflet映射由"Panes"的集合组成,其视图顺序是使用z-index控制的.每个窗格包含一个图层集合.默认窗格显示顺序为tile-> shadows-> overlays-> markers-> popups.像Etienne所述,您可以通过调用bringToFront()bringToBack()来控制路径"在叠加面板中的显示顺序. L.FeatureGroup也具有这些方法,因此您可以根据需要立即更改叠加组的顺序.

A Leaflet map consists of a collection of "Panes" whose view order is controlled using z-index. Each pane contains a collection of Layers The default pane display order is tiles->shadows->overlays->markers->popups. Like Etienne described, you can control the display order of Paths within the overlays pane by calling bringToFront() or bringToBack(). L.FeatureGroup also has these methods so you can change the order of groups of overlays at once if you need to.

如果要更改整个窗格的显示顺序,则只需使用CSS更改窗格的z-index.

If you want to change the display order of a whole pane then you just change the z-index of the pane using CSS.

如果您要添加新的地图"窗格...那么我还不确定如何做.

If you want to add a new Map pane...well I'm not sure how to do that yet.

http://leafletjs.com/reference.html#map-panes

http://leafletjs.com/reference.html#featuregroup

这篇关于leaflet.js中的图层排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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