简体   繁体   English

如何在传单js中添加侧边栏覆盖?

[英]How to add sidebar overlay in leaflet js?

I need to add an interactive sidebar to my map.我需要在我的地图上添加一个交互式侧边栏。

Im using this as an example to add the sidebar: https://www.w3schools.com/w3css/w3css_sidebar.asp我以此为例添加侧边栏: https : //www.w3schools.com/w3css/w3css_sidebar.asp

Ive tried using the sidebar codes provided but it doesnt seem to add anything to the map.我试过使用提供的侧边栏代码,但它似乎没有向地图添加任何内容。 I need a sidebar overlay which is the same height and width as the map.我需要一个与地图高度和宽度相同的侧边栏叠加层。 Is there any way possible that a sidebar can be added?有什么办法可以添加侧边栏吗? If anyone has a solution do let me know or you can write the code down as well.如果有人有解决方案,请告诉我,或者您也可以写下代码。

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
        integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
        crossorigin=""/>
        <!-- Make sure you put this AFTER Leaflet's CSS -->
        <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
        integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
        crossorigin=""></script>
        <style>
            body {
                margin: 0;
                padding: 0;
            }
            #map {
                position: absolute;
                height: 100%;
                width: 100%;
                background-color: rgb(38, 38, 38);
            }
        </style>
        <title>Map Testing</title>
    </head>
    <body>
        <h2>Leaflet JS</h2>
        <div id="map"></div>
        <script src="myscripts.js"></script>
    </body>
</html>

If you use the example from you, you have to add in the css a high z-index (over 1000), else it is showing below the map and you don't see the sidebar.如果您使用您提供的示例,则必须在 css 中添加一个高 z-index(超过 1000),否则它会显示在地图下方并且您看不到侧边栏。

I use this sidebar, look into it: https://github.com/Turbo87/sidebar-v2我使用这个侧边栏,查看它: https : //github.com/Turbo87/sidebar-v2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM