简体   繁体   English

Google映射CSS问题

[英]Google maps CSS problems

I had a googlemaps map covering my whole page and i wanted a cool menu showing up above the map. 我有一张覆盖整个页面的googlemaps地图,我想在地图上方显示一个很酷的菜单。 So i found this tutorial http://tympanus.net/codrops/2013/08/09/building-a-circular-navigation-with-css-transforms/ about a cool menu. 因此,我发现了有关酷菜单的本教程http://tympanus.net/codrops/2013/08/09/building-a-circular-navigation-with-css-transforms/ My problem is that no the menu looks good and works as it should but somehow my maps is gone behind all this. 我的问题是,没有一个菜单看起来不错并且不能正常工作,但是我的地图却不知所措。 It doesn't respond to z-index it is still behind everything. 它没有响应z-index,它仍然落后于一切。 And it is not covering my whole screen anymore. 而且它不再覆盖我的整个屏幕。

Here is my googlemap: 这是我的谷歌地图:

  <script>
function initialize() {
    var mapCanvas = document.getElementById('map-canvas');
    var mapOptions = {
        center: new google.maps.LatLng(0, 0),
        zoom: 4,
        mapTypeId: google.maps.MapTypeId.SATELLITE
    }
    var map = new google.maps.Map(mapCanvas, mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);

<div id="map-canvas"></div>

And here is the css for the map: 这是地图的CSS:

        #map-canvas {
     position:absolute;
     top:0;
     bottom:0;
     left:0;
     right:0;
     overflow:hidden;
     z-index:-1;
 }

here is the menu html and js: 这是html和js菜单:

    <div class="component">
<!-- Start Nav Structure -->
<button class="cn-button" id="cn-button">-</button>
<div class="cn-wrapper opened-nav" id="cn-wrapper">
    <ul>
        <li><a href="#"><span class="icon-picture"></span></a></li>
        <li><a href="#"><span class="icon-headphones"></span></a></li>
        <li><a href="#"><span class="icon-home"></span></a></li>
        <li><a href="#"><span class="icon-facetime-video"></span></a></li>
        <li><a href="#"><span class="icon-envelope-alt"></span></a></li>
    </ul>
</div>
<div id="cn-overlay" class="cn-overlay on-overlay"></div>
<!-- End Nav Structure -->

    (function () {

    var button = document.getElementById('cn-button'),
        wrapper = document.getElementById('cn-wrapper'),
        overlay = document.getElementById('cn-overlay');

    //open and close menu when the button is clicked
    var open = false;
    button.addEventListener('click', handler, false);
    button.addEventListener('focus', handler, false);
    wrapper.addEventListener('click', cnhandle, false);

    function cnhandle(e) {
        e.stopPropagation();
    }

    function handler(e) {
        if (!e) var e = window.event;
        e.stopPropagation();//so that it doesn't trigger click event on document

        if (!open) {
            openNav();
        }
        else {
            closeNav();
        }
    }
    function openNav() {
        open = true;
        button.innerHTML = "-";
        classie.add(overlay, 'on-overlay');
        classie.add(wrapper, 'opened-nav');
    }
    function closeNav() {
        open = false;
        button.innerHTML = "+";
        classie.remove(overlay, 'on-overlay');
        classie.remove(wrapper, 'opened-nav');
    }
    document.addEventListener('click', closeNav);

})();

How can i find out what is blocking the maps from creating as it should? 我如何找出阻碍地图创建的原因? 在此处输入图片说明

Try the following: 请尝试以下操作:

html, body  {
    height: 100%;
    width: 100%;
    margin: 0px;
    padding: 0px;
}
.mapContainer  {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}
#map-canvas  {
    min-height: 100%;
    height: 100%;
    min-width: 100%;
    width: 100%;
}
.component  {
    position: relative;
    z-index: 99;
}

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

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