5

我试图在“clusterclick”事件中向 markerCluster 添加一个 infoBubble,但 infoBubble.Open 方法要求绑定一个“marker”参数。问题是 markerCluster 不是 google.maps.Point 所以不可能将 infoBubble 绑定到它。

我将 markerCluster 的位置分配给 infoBubble,但 infoBubble 在新位置重绘,将标记从其位置移动。

有没有人有同样的问题?有没有不修改原始 infoBubble 代码的解决方案?

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/

4

2 回答 2

6

解决问题1: marker参数是可选的如果我只是从不分配它,问题就解决了。

采用:

infoBubble.setPossition(latLng);
infoBubble.open(map);

不是:

infoBubble.open(map, marker);

问题2:但是现在市场上出现了infoBubble,有没有办法让它向上移动?

解决问题2

我修改了 InfoBubble sourceCode 以包含一个 offsetParameter,然后在绘图函数中添加像素:

InfoBubble.prototype.PIXEL_OFFSET = 0
...
var top = pos.y - (height + arrowSize); if (anchorHeight) { top -= anchorHeight; } top -= this.PIXEL_OFFSET

以防万一有人遇到同样的问题

于 2011-05-24T20:50:32.897 回答
2

将此添加到第 93 行(在其他选项字段下方)

if (options['pixelOffset'] == undefined) {
    options['pixelOffset'] = this.PIXEL_OFFSET_;
}

在第 182 行附近,添加这个

InfoBubble.prototype.PIXEL_OFFSET_ = [0.0];

在第 908 行附近,添加以下内容:

top -= this.get('pixelOffset')[1];  // Add offset Y.
left -= this.get('pixelOffset')[0]; // Add offset X.

上面的行应该放在上面:

this.bubble_.style['top'] = this.px(top);
this.bubble_.style['left'] = this.px(left);

现在在你的建设中你可以做的选择

var popupWindowOptions = {
    backgroundColor: '#2B2B2B',
    arrowStyle: 0,
    pixelOffset: [0,16]
 };

 this.popupWindow = new InfoBubble(popupWindowOptions);
于 2013-03-21T06:46:36.630 回答