Google Maps API V3 + MarkerClustererのInfobubble
-
13-11-2019 - |
質問
私は 'clusterclick'イベントのmarkerClusterにInfoBubbleを追加しようとしていましたが、InfoBubble.openメソッドは 'marker'パラメータとバインドするように依頼していました。問題は、MarkerClusterがgoogle.maps.Pointではないということです。
MarkerClusterのinfobubbleに割り当てられましたが、Infobbleは新しい位置にマーカーをその可能なものから移動します。
誰もが同じ問題を抱えていましたか?元のInfoBubbleコードを変更せずに解決策がありますか?
http:// google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble /
解決
解決策の問題1: Markerパラメータはオプションであっただけで、その問題は解決されます。
使用:
.
infoBubble.setPossition(latLng);
infoBubble.open(map);
.
infoBubble.open(map, marker);
問題2:しかし今、インフォバブルは市場に渡って現れ、それを上に移動させる方法はありますか?
解決策の問題2 :
InfoBubble SourceCodeを変更して、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);
.