我试图向‘infoBubble’事件中的一个标记添加一个标记,但是infoBubble.Open方法请求一个‘markerCluster’参数来绑定。问题是markerCluster不是google.maps.Point,所以不可能将infoBubble绑定到它。
我将markerCluster的位置分配给了infoBubble,但infoBubble在新位置重绘,将标记从其位置移动。
有没有人遇到过同样的问题?有没有不修改原始infoBubble代码的解决方案?
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/
发布于 2011-05-25 04:50:33
解决方案问题1:标记参数是可选的,如果我只是简单地从不分配它,问题就解决了。
使用:
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以防有人遇到同样的问题
发布于 2013-03-21 14:46:37
将此代码添加到第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);https://stackoverflow.com/questions/5997070
复制相似问题