我试图在“clusterclick”事件中向 markerCluster 添加一个 infoBubble,但 infoBubble.Open 方法要求绑定(bind)一个“marker”参数。问题是 markerCluster 不是 google.maps.Point 所以不可能将 infoBubble 绑定(bind)到它。
我将 markerCluster 的位置分配给 infoBubble,但 infoBubble 在新位置重绘,将标记从其位置移动。
有没有人有同样的问题?有没有不修改原始 infoBubble 代码的解决方案?
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/
最佳答案
将此添加到第 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);
现在在你的 build 中你可以做的选择
var popupWindowOptions = {
backgroundColor: '#2B2B2B',
arrowStyle: 0,
pixelOffset: [0,16]
};
this.popupWindow = new InfoBubble(popupWindowOptions);
关于google-maps - 谷歌地图 api v3 + markClusterer 中的 infoBubble,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5997070/