我有一个折线列表,就像谷歌地图在这里,当我点击折线时,我希望信息窗口出现在我点击的位置,这个函数可以很好地实现这个功能。
function mapsInfoWindow(polyline, content) {
google.maps.event.addListener(polyline, 'click', function(event) {
infowindow.content = content;
infowindow.position = event.latLng;
infowindow.open(map);
});
}
问题出现在我点击列表时(使用相同的函数),显然事件没有latLng,但我仍希望infowindow像在Google地图链接中单击列表时一样显示在折线的中间位置。我之前提到的。
尝试过LatLngBounds(); 但这给出的是折线创建区域的实际中心,而不是我需要的中间位置。
有任何想法吗?