google-maps - 谷歌地图 api v3 + markClusterer 中的 infoBubble

标签 google-maps google-maps-api-3 markerclusterer

我试图在“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/

相关文章:

javascript - Google Maps API v3(一次打开一个信息窗口)

ios - 谷歌地图 animateToCameraPosition iOS7 问题

google-maps - Google Maps v3 map.getBounds().containsLatLng 不是函数

javascript - 如何使用 map 上的按钮(不在 map 下方或上方)将 map 居中到 Google Map API 3 中的默认位置?

javascript - 强制停止 map 拖动

google-maps - MarkerClusterer 完成后触发事件

java - com.google.android.maps.MapView ClassNotFoundException

javascript - 使用 JavaScript 禁用缩放谷歌地图?

ios - 传递依赖项,包括使用Google Map和集群的静态二进制文件

javascript - 单击 MarkerClusterer 时,Google map API v3 事件单击会引发?