地图上方的 Bootstrap Angular Leaflet Div

Joh*_*ohn 3 twitter-bootstrap leaflet typescript bootstrap-4 angular

我试图在地图上方放置一个 div ,以放置一些操作,例如过滤器和其他内容,但该 div 仅在我移动地图时出现,并且它位于地图后面。

组件CSS:

.map {
    padding: 0;
    position:relative;
    width:100% ;
    height: 100%;
}

.mapContainer{
        width: 100vw;
        height: 92.6vh; /* Fallback for browsers that do not support Custom Properties */
        height: calc(var(--vh, 1vh) * 92.6);
        padding: 0 ;
}

.overlay {
    width: 100px;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    background-color: rgba(255, 50, 50, 0.5);
}
Run Code Online (Sandbox Code Playgroud)

组件 html :

<div class="container-fluid" >
    <div class="row">
        <div class="col-sm-2">
            <div *ngIf="city">
                <p>{{city.name}}  </p>
            </div>
        </div>
    <div class="col-sm-10 mapContainer" >
        <div leaflet class="map"
            [leafletOptions]="options"
            [leafletFitBounds]="bounds"
            (leafletMapReady)="onMapReady($event)"
            [leafletMarkerCluster]="markerClusterData"   
            [leafletMarkerClusterOptions]="markerClusterOptions"
            (leafletMarkerClusterReady)="markerClusterReady($event)">
        </div>
        <div class = "overlay">
            <input type="radio" class = "someButton">Foo Bar
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

kbo*_*oul 5

position: absolute由于您已在类中使用,因此overlay您可以应用该z-index属性equal or more 1000,使其位于 z-index 值较低的地图元素的前面。

.overlay {
     width: 100px;
     position: absolute;
     top: 0;
     left: 0;
     bottom: 0;
     background-color: rgba(255, 50, 50, 0.5);
     z-index: 1000
}
Run Code Online (Sandbox Code Playgroud)

演示