我正试图将一个infobbble添加到'clusterclick'事件中的markercluster,但是infobubble.open方法要求“标记”参数绑定。问题是MarkerCluster不是Google.maps.point,因此它不是将infobbble绑定到它的positible。

我分配了对infobbble的markercluster,但在新位置中的infobbble重绘了从它的可能移动的标记。

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

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

有帮助吗?

解决方案

解决方案问题1: 标记参数是可选的,如果我只是根本从未分配它,则解决问题。

使用:

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

不是:

infoBubble.open(map, marker);
.

问题2:但现在infobbble出现在市场上,有没有办法将其移动到??

解决方案问题2

我修改了infobbble源代码以包含offsetParameter,然后在绘制功能中添加像素:

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

以防某人有同样的问题

其他提示

将此添加到第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);
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top