谷歌地图infowindow事件公开 [英] Google maps infowindow events on open

查看:99
本文介绍了谷歌地图infowindow事件公开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用谷歌融合表和谷歌地图,事情是,我的标记显示正确,但我想插入一些图像到inforwindow。
所以问题是我会查询这些标记的位置,这些标记可以有很多类别(这就是为什么我不能使用合并表)。当用户点击标记时,infowindow会在标记上显示并显示信息。它过去只包含类别的文本,但我想从每个类别中检索图标以在infowindow上显示该图标。
问题是第二个查询花费的时间比显示信息窗口的时间要长。
所以我做了一个蹩脚的修复,我添加了

$ $ $''code $('#infoWindowsCatDer')。append(info);

在第二个查询结束时,所以我猜你可以看到问题,如果窗口显示的时间比查询长一点。这是应该由事件处理的东西吧?



是否有一个事件

  lastWindow.open(地图); 

所以当infowindow完全打开时,它可以附加图片吗?


当InfoWindow对象被附加(完全加载)到DOM时,触发事件 domready 事件。

解决方案

您可以在API文档中看到以下内容: https://developers.google.com/ maps / documentation / javascript / reference#InfoWindow

然后,您可以让一个像下面这样的侦听器在载入内容后将内容加载到infoWindow中:

  google.maps.event.addListener(referenceToInfoWindow,'domready',function(){
// code to动态加载新内容到infowindow
//例如:
// var existing_content = referenceToInfoWindow.getContent();
// var new_content =...;
/ / referenceToInfoWindow.setContent(existing_content + new_content);
});


Hi I am using google fusion tables and google maps, the thing is that my markers show up correctly, but I want to insert some images into the inforwindow. So the thing is that I do queries to find the location of those markers, and those markers can have many categories (that is why i couldnt use a merged table). And when the user clicks on the marker, the infowindow displays and shows the info on the marker. It used to include just a text of the categories, but I want to retrieve the icon from each category to display that on the infowindow. The thing is that the second query takes longer than the time it takes to display the info window. So i did a lame fix, I added

$('#infoWindowsCatDer').append(info);

at the end of the second query, so I guess you can see the problem, what happens if the windows takes a little bit longer to display than the query. This is something that should be handled by events right?

Is there an event for

lastWindow.open(map);

So when the infowindow is completly open it can append the images?

解决方案

The InfoWindow object fires the event domready event when it is attached (fully loaded) to the DOM. You can see this in the API docs: https://developers.google.com/maps/documentation/javascript/reference#InfoWindow

You could then have a listener like the one below to load content into the infoWindow after it has loaded itself:

google.maps.event.addListener(referenceToInfoWindow, 'domready', function(){
    //code to dynamically load new content to infowindow
    //for example:
    //    var existing_content = referenceToInfoWindow.getContent();
    //    var new_content = "...";
    //    referenceToInfoWindow.setContent(existing_content + new_content);
}); 

这篇关于谷歌地图infowindow事件公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆