Gia*_*rlo 5 html javascript css google-maps google-maps-api-3
我正在开发一个应用程序,它使用谷歌地图api v3来显示标记和infowindows.
好吧,我有一个存储在一个数组中的N个标记和一个用于显示一些信息的全局信息窗口.
只需单击以这种方式创建的标记即可显示infowindow内容:
/* global js stuff */
var g_map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var g_current_popup = new google.maps.InfoWindow({ content: "" });
var g_markers = [];
/* create marker function */
function addMarker(p_infowindow_contents)
{
  var l_marker = new google.maps.Marker( all the stuff needed );
  google.maps.event.addListener(l_marker, 'click', function()  
  {  
      g_current_popup.close(); // if already open, it must be closed and reloaded
      g_current_popup.setContent(p_infowindow_contents);
      g_current_popup.open(g_map, l_marker);
  });
  g_markers.push(l_marker);
}
一切都按预期工作,除了一点点图形故障:当infowindow出现时,我看到infowindow'tip'位于一个未知位置十分之一秒,然后它消失了,我看到了正确的信息窗口.
看看这个截图在提示消失之前拍摄:

有没有人经历过这样的事情?可能是一些CSS问题?
谢谢
看起来这不是您的代码的问题,我认为这更有可能是浏览器的问题。我能够通过查看 Google 在 Firefox 中提供的 infowindow 示例来验证相同的内容,但在 Chrome 中则不行:
https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple
当地图必须滚动以适应信息窗口时,这种情况似乎会更明显地发生,但我想说这并不是必须这样做的要求。这很可能只是屏幕需要几个时钟周期才能赶上 DOM 的产物。