2

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

        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,但它没有效果。我相信这与谷歌地图信息框中提出的问题相同,高于所有其他内容 z-index 不起作用

我很抱歉没有附加 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复制而来。

4

1 回答 1

4

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

pane: "mapPane"

这将把它放在标记后面。如果您希望它成为 infowindow 的替代品,请复制该示例中的代码:

pane: "floatPane"

您参考的文档中

于 2014-05-30T20:19:51.300 回答