google-maps - 谷歌地图 : infobox turns up behind markers?

标签 google-maps google-maps-api-3 z-index infowindow infobox

出于某种原因,我的信息框出现在标记后面。我知道这应该是不可能的,但事实却并非如此。这是我的标记的代码:

        var yellowCircle={
          path: google.maps.SymbolPath.CIRCLE,
          scale: 5,
          fillColor: '#faeadd',
          strokeColor: 'black',
          fillOpacity: 1.0,
          strokeWeight: 0.5,
          zIndex:-10
        };

        var yellowBlackCircle={
          path: google.maps.SymbolPath.CIRCLE,
          scale: 5,
          fillColor: '#faeadd',
          strokeColor: 'black',
          fillOpacity: 1.0,
          strokeWeight: 1.5,
          zIndex:-10

        };


            var marker = new google.maps.Marker({       
                position: new google.maps.LatLng(Lat,Lng), 
                map: map,  
                title: name,
                icon:yellowCircle,
                url:url,
                zIndex:-1,
            });

             google.maps.event.addListener(marker, 'mouseover', function() {
            marker.setIcon(yellowBlackCircle);
              });

            google.maps.event.addListener(marker, 'mouseout', function() {
                marker.setIcon(yellowCircle);
                });

             google.maps.event.addListener(marker, 'click', function() {
              window.location.href = url;
             });

以及我的信息框的代码:

    var myOptions = {
                content: name
                ,boxStyle: {
                  border: "1px solid black"
                 ,textAlign: "center"
                 ,fontSize: "12pt"
                 ,fontType: "arial"
                 ,backgroundColor: "#faeadd"
                 ,fontWeight: "bold"
                 ,zIndex:1
                }
               ,disableAutoPan: true
               ,pixelOffset: new google.maps.Size(-getTextWidth(name, "bold 12pt arial")/2,-30)
               ,position: new google.maps.LatLng(49.47216, -123.76307)
               ,closeBoxURL: ""
               ,isHidden: false
               ,pane: "mapPane"
               ,enableEventPropagation: true
               ,zIndex:1
            };

            var infobox = new InfoBox(myOptions);

             google.maps.event.addListener(marker, 'mouseover', function() {
                infobox.open(map,marker);
              });

              google.maps.event.addListener(marker, 'mouseout', function() {
                infobox.close();
              });

你可以看到我什至尝试过设置 zIndex'es,但没有效果。我相信这与 google maps infobox above all other content z-index does not work 中提出的问题相同。 。

我很抱歉没有附加 jsfiddle - 即使我将 infobox_packed.js 上传到存储库以便我可以将其添加为外部资源,我似乎也无法使其工作。相反,整个事情是这样的: http://www.kaarebmikkelsen.dk/wp-content/uploads/2014/05/test2.html

信息框代码大部分复制自https://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html .

最佳答案

您的代码来自制作“ map 标签”的示例,并且您将 infoBox 附加到 mapPane:

pane: "mapPane"

这会将其放在标记后面。如果您希望它成为信息窗口的替代品,请复制该示例中的代码:

pane: "floatPane"

来自the documentation you reference

关于google-maps - 谷歌地图 : infobox turns up behind markers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23962607/

相关文章:

android - 一个api给出的高坐标

android - Apple Maps 和 Google Maps API 可行性

javascript - 显示/隐藏类别标记。不使用 MarkerCluster

javascript - 自定义 Google Map API V3 缩放按钮

css - reactJS 和 Material UI 中的建议下拉列表无法使用 zIndex

css - 是否可以设置伪元素在其父元素下方的堆叠顺序?

javascript - map 已经创建时如何设置谷歌地图背景。 map.setOptions() 不起作用

android - Flutter 应用程序中的 Google map 未显示

javascript - 如何在 Google 地点 api 中使用附近搜索查找地点详细信息?

javascript - Popper菜单上的Z-Index?