我在这方面已经坚持了一段时间,因此简化了我的需求。当你点击一个标记时,一个信息窗口就会打开,当用户缩放时,我希望那个标记位于地图的中心。这不起作用,但我认为它很接近:
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
google.maps.event.addListener(map, 'zoom_changed', function() {
infoWindow.setCenter(infoWindow.getCenter());
});
} http://www.hostelbars.com/map_test_v3_1.html
发布于 2011-05-10 04:02:11
我认为问题是你做infoWindow.setCenter(infoWindow.getCenter());,这会得到infoWindow的中心,而不是marker。试着这样做:
infoWindow.setCenter(marker.getPosition());
https://stackoverflow.com/questions/5941775
复制相似问题