Google 地图信息框,关闭按钮似乎不起作用
我正在开发 Google 地图应用程序,并使用 Google 的信息框插件,但遇到了一些麻烦。
似乎关闭按钮不再适用于信息框,这很奇怪,因为我之前确实让它工作过,因为我正在将信息亭应用程序转变为网络应用程序。我为此使用了自定义关闭按钮,但即使我将其切换为谷歌的默认关闭按钮,我也会得到相同的结果。仅当您单击地图上的另一个标记以打开另一个信息框时,信息框才会关闭。一旦打开,似乎就无法将其移除。该代码从信息亭到该应用程序的网络版本没有更改...
这是我用来实例化标记的一些代码:
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;
}
非常感谢任何有关此问题的帮助。
提前致谢!
编辑 - 我使用的是 INFOBOX API,而不是地图 API 中的 InfoWindow 对象。这就是我所说的: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
格雷厄姆
I'm working on a Google Maps app, and using the infobox plugin from Google I've run into a bit of trouble.
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. 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. This is what I'm talking about: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
Graham
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了这个问题。我使用主 CSS 样式表来设置信息框的样式,而不是 Javascript 中的 boxStyle。当我将不透明度设置为 1.0 以外的任何内容(或完全删除)时,关闭按钮将可见,但不起作用。我的建议是检查以确保您的信息框不会继承其他任何地方的不透明度。
I had this problem. I used my main CSS stylesheet to style my infobox rather than boxStyle in the Javascript. 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. My advice would be to check to make sure your infobox does not inherit opacity from anywhere else.