【发布时间】: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