【问题标题】:Bootstrap Angular Leaflet Div above map地图上方的 Bootstrap Angular Leaflet Div
【发布时间】:2019-04-10 21:00:27
【问题描述】:

我正在尝试在地图上方放置一个 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);
}

组件 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>

【问题讨论】:

    标签: angular typescript twitter-bootstrap bootstrap-4 leaflet


    【解决方案1】:

    由于您在overlay 类中使用了position: absolute,您可以将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
    }
    

    Demo

    【讨论】:

    • 小提示:如果您使用 geoman 编辑器进行传单,控件的 z-index 为 1000。只需将叠加层的 z-index 设置为 1001 即可
    猜你喜欢
    • 1970-01-01
    • 2019-07-26
    • 1970-01-01
    • 1970-01-01
    • 2022-08-05
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多