Google Maps API v3控件显示在地图后面

Google Maps API v3 controls showing up behind map

本文关键字:地图 显示 控件 Maps API v3 Google      更新时间:2023-09-26

问候&你好,

这是我第一次使用谷歌地图API,我正在使用WordPress和Genesis框架,

我正在学习关于……的教程http://tympanus.net/codrops/2011/04/13/interactive-google-map/

我已经得到了一个谷歌地图显示在地图页面,

http://www.foodtrucksnashville.com/map/

然而,你会注意到地图控件在地图的下面。嗯。

不知道。需要帮助/指引方向

再次感谢stackoverflow社区。

下面是init.js中的代码:
var map, geocoder, marker, ey, my, mouseDown = false;
var o = {
    init: function () {
        this.map.init();
    },
    map: {
        size: function () {
            // so it's a loverly sqware.
            var w = jQuery('.content-sidebar #content').width(),
                h = 440;
            return {
                width: w,
                height: h
            }
        },
        data: {
            zoom: 13,
            center: new google.maps.LatLng(36.165389, -86.783237), // Nashville TN Capitol BLDG
            scrollwheel: false,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        },
        init: function () {
            // get the map size
            var size = o.map.size();
            // add some css to the #map div based on the size
            jQuery('#map').css({
                width: size.width,
                height: size.height,
            });
            // make a new google map in the #map div and pass it the map data
            map = new google.maps.Map(document.getElementById('map'), o.map.data), geocoder = new google.maps.Geocoder();
            /*
            // add eventlistener to map to hide posts when dragging?
            google.maps.event.addListener(map, 'dragstart', function () {
                jQuery('.posts').hide();
            });
            */
        }
    } // end map
} // end o object
jQuery(window).load(function () {
    o.init();
});

我的问题来自我的css文件上的z-index。我试着一个一个地禁用,直到我找到它。

figure.rounded img {
width: 100%;
z-index: -1;  /*  Here he is  */
position: relative;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}

终于弄明白是怎么回事了,在google Maps API v3的群组中找到了解决方案,

http://code.google.com/apis/maps/documentation/javascript/forum.html?place=topic%2Fgoogle-maps-js-api-v3%2F8dOLhjNQzmo%2Fdiscussion

在我的子主题中隐藏了一些CSS属性,这些属性针对的是一些max-width: 100%的图像。

一旦我用max-width删除了所有针对img元素的引用,生活又开始了。