5

I'm using Google Map APIv2. On my webpage I've a sidebar containing a list of markers with onclick event executing showDetails method, that looks like:

GMarker.prototype.showDetails=function() { map.panTo(this.getLatLng()); this.openInfoWindowHtml(this.details); };

The problem is that i cannot both panTo and openInfoWindowHtml in one method, it pans but won't open tooltip and when i change method to:

GMarker.prototype.showDetails=function() { this.openInfoWindowHtml(this.details); map.panTo(this.getLatLng()); }; it opens tooltip but won't center map to the marker's anchor coordinates. Even using wait function doesn't solve my problem. What am I doing wrong?

4

2 回答 2

1

你需要先做一个 addListener 来等到地图完成移动'moveend'事件。然后在您的事件处理程序中调用您创建的侦听器上的 removeListener 以便事件处理程序只运行一次。之后在事件处理程序中打开您的信息窗口。

于 2010-04-19T23:40:38.833 回答
0

openInfoWindowHtml 方法应该触发 panto 将信息窗口放在视口中

IE

标记在视口之外,您触发该标记上的信息窗口 - 地图平移到该位置 +/-,以便信息窗口在视口中居中

于 2010-05-14T19:15:02.153 回答