leaflet地图为L.geoJson设置图层顺序
1、为地图创建窗格,设置窗格的层级
var myPane = this.map.createPane("myPaneName")
myPane.style.zIndex = 420
var myPanr = this.map.createPane("myPaneNamr")
myPanr.style.zIndex = 440
var myPanw = this.map.createPane("myPaneNamw")
myPanw.style.zIndex = 450
2、添加geoJson的时候设置pane
var layer = L.geoJson(data, {
color: ‘#cfcfc4’,
weight: 3,
fill: false,
pane:item.name == '**' ? 'myPaneNamr' : item.name == '**' ? 'myPaneName' : 'myPaneName',
fillColor: "#fff",
fillOpacity: 0,
});
搞定!!!