简体   繁体   English

Google Maps Infobox,关闭按钮似乎不起作用

[英]Google Maps Infobox, close button does not seem to work

I'm working on a Google Maps app, and using the infobox plugin from Google I've run into a bit of trouble. 我正在使用Google Maps应用程序,并且使用Google的infobox插件遇到了一些麻烦。

It seems that the close button no longer wants to work on the infoboxes, which is strange because I did have it working before, as I am turning a kiosk app into a web app. 似乎关闭按钮不再希望在信息框上工作,这很奇怪,因为在将信息亭应用程序变成网络应用程序之前,我确实确实可以使用它。 I am using a custom close button for this, but even if I switch it to google's default close button I get the same result. 我为此使用了一个自定义关闭按钮,但是即使将其切换为google的默认关闭按钮,我也会得到相同的结果。 The infobox only closes when you click another marker on the map to open another infobox. 仅当您单击地图上的另一个标记以打开另一个信息框时,信息框才会关闭。 Once one is open, it seems to be impossible to remove it. 打开后,似乎无法将其删除。 The code has not changed from the kiosk to the web version of this app... 该应用程序的代码未从信息亭更改为网络版本...

Here is some code I'm using to instantiate the markers: 这是一些我用来实例化标记的代码:

var displayingInfoBox;

// Options for the infobox
var popoverOptions = {

        disableAutoPan : false,
        maxWidth : 0,
        closeBoxMargin : '8px 32px',
        closeBoxURL : 'url/to/close_button/image.png',  
        infoBoxClearance : new google.maps.Size(50,50),
        isHidden : false,
        enableEventPropagation : true,

        boxStyle: {
            border      : 'none',
            opacity     : 1.0,
            background  : "transparent url( 'url/to/background/image.png' ) no-repeat 0 0",
            width: "266px",
            height: "109px"
        }
    };

// Add listener to the marker to open the overlay -- where popupInfo is the content to display inside the popover and marker is the marker on the map
google.maps.event.addListener(marker, 'click', function( event ) {
        createOverlay( marker, popupInfo, new google.maps.Size(-35, -235))
    });

// Method to show in the overlay
function createOverlay(marker_, content_, offset_) {

    // close the previous overlay if there was one.
    VW.Map.closeInfoBox();

    // set the provided content to the popover options
    popoverOptions.content = content_;
    popoverOptions.pixelOffset = offset_;

    // use the infobox lib to create an overlay
    displayingInfoBox = new InfoBox(popoverOptions);

    // show the overlay over the marker passed in
    displayingInfoBox.open(myMap, marker_);

    // return in case the caller wants to do something with this.
    return displayingInfoBox;
}

Any help with this is much appreciated. 非常感谢您提供任何帮助。

Thanks in advance! 提前致谢!

EDIT -- I am using the INFOBOX API, and not the InfoWindow object from the maps API. 编辑 -我使用的是INFOBOX API,而不是maps API中的InfoWindow对象。 This is what I'm talking about: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html 这就是我正在谈论的内容: http : //google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html

Graham 格雷厄姆

I had this problem. 我有这个问题。 I used my main CSS stylesheet to style my infobox rather than boxStyle in the Javascript. 我使用主要的CSS样式表来设置信息框的样式,而不是Javascript中的boxStyle。 When I had the opacity setting on anything other than 1.0 (or removed altogether) the close button would be visible but would not work. 当我对1.0以外的任何物体进行不透明度设置(或完全删除)时,关闭按钮将可见,但将不起作用。 My advice would be to check to make sure your infobox does not inherit opacity from anywhere else. 我的建议是检查以确保您的信息框不会继承其他任何地方的不透明度。

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

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