【问题标题】:Google Maps Infobox, close button does not seem to work谷歌地图信息框,关闭按钮似乎不起作用
【发布时间】:2012-02-16 23:27:17
【问题描述】:

我正在开发一个谷歌地图应用程序,使用谷歌的信息框插件我遇到了一些麻烦。

似乎关闭按钮不再需要在信息框上工作,这很奇怪,因为我之前确实有它工作过,因为我正在将信息亭应用程序转变为网络应用程序。我为此使用了自定义关闭按钮,但即使我将其切换到谷歌的默认关闭按钮,我也会得到相同的结果。仅当您单击地图上的另一个标记以打开另一个信息框时,该信息框才会关闭。一旦打开,似乎无法将其删除。从信息亭到此应用的网页版,代码没有更改...

这是我用来实例化标记的一些代码:

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;
}

非常感谢任何帮助。

提前致谢!

EDIT -- 我使用的是 INFOBOX API,而不是地图 API 中的 InfoWindow 对象。这就是我要说的:http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html

格雷厄姆

【问题讨论】:

    标签: javascript google-maps-api-3 google-maps-markers


    【解决方案1】:

    我遇到了这个问题。我使用我的主要 CSS 样式表来设置我的信息框而不是 Javascript 中的 boxStyle。当我对 1.0 以外的任何内容(或完全删除)进行不透明度设置时,关闭按钮将可见但不起作用。我的建议是检查以确保您的信息框不会从其他任何地方继承不透明度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-10
      • 2014-04-06
      • 1970-01-01
      • 2018-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多