0
我正在使用CSS按鈕在leaflet.js環境中切換地圖圖層。我有25層。我想添加1個按鈕,可以打開/關閉所有圖層。這裏是我用來切換圖層的代碼。切換單張中的所有圖層
<div id="projects" class="layers" style="width: 400px; height: 600px; overflow-y: scroll;">
<a id="1" class="1" data-control="layer" data-layer-level="" data-layer-name="1" href="#1">1</a>
<a id="2" class="2" data-control="layer" data-layer-level="" data-layer-name="2" href="#2">2</a>
<a id="3" class="3" data-control="layer" data-layer-level="" data-layer-name="3" href="#3">3</a>
<a id="4" class="4" data-control="layer" data-layer-level="" data-layer-name="4" href="#4">4</a>
<a id="5" class="5" data-control="layer" data-layer-level="" data-layer-name="5" href="#5">5</a>
<a id="6" class="6" data-control="layer" data-layer-level="" data-layer-name="6" href="#6">6</a>
<a id="7" class="7" data-control="layer" data-layer-level="" data-layer-name="7" href="#7">7</a>
<a id="25" class="25" data-control="layer" data-layer-level="" data-layer-name="25" href="#25">25</a>
</div>
<script>