本文介绍了谷歌地图js api版本3 infowindow故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



那么,我有N个标记存储在一个数组中,并且使用了一个全局infowindow显示一些信息。



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 = [];
$ b $ *创建标记函数* /
函数addMarker(p_infowindow_contents)
{
var l_marker = new google.maps.Marker(所有需要的东西);
google.maps.event.addListener(l_marker,'click',function()
{
g_current_popup.close(); //如果已经打开,必须关闭并重新加载$ ​​b $ b g_current_popup.setContent(p_infowindow_contents);
g_current_popup.open(g_map,l_marker);
});
g_markers.push(l_marker);



$ b

一切都按预期工作,除了一点点图形故障:当infowindow是出现的时候,我看到infowindow'小费'位于未知位置十分之一秒,然后它消失了,我看到了正确的infowindow。



看看这个截图在提示消失之前就拿走了:



有人经历过这样的事吗?
可能是一些CSS问题吗?



谢谢

解决方案



当地图不得不滚动以适应infowindow时,它似乎更明显地发生,但我会说它不是它的要求。这可能只是屏幕上的一个工件,需要几个时钟周期才能跟上DOM。

I am developing an application which uses google maps api v3 to show markers and infowindows.

Well, I have N markers stored within an array and a global infowindow used to show some information.

The infowindow contents are shown simply by clicking a marker, created in this way:

/* 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);
}

Everything works as expected, except for a little graphical glitch: when the infowindow is appearing, I see the infowindow 'tip' positioned at an unknown location for a tenth of a second, then it disappears and I see the correct infowindow.

Look at this screenshot took just before the tip disappears:

Does anyone experienced something like this?Could it be some CSS issue?

Thanks

解决方案

It does not look like this is a problem with your code, I think it more likely a browser issue. I was able to validate the same thing looking at the infowindow example that Google provides in Firefox, but not in Chrome:

https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple

it seems to happen more visibly when the map has to scroll to fit the infowindow, but I would say that it is not a requirement for it to do so. It is likely just an artifact with the screen taking a few clock cycles to catch up with the DOM.

这篇关于谷歌地图js api版本3 infowindow故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 02:54