谷歌在开放时映射infowindow事件

Jua*_*ego 16 javascript jquery google-maps google-fusion-tables

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

$('#infoWindowsCatDer').append(info);
Run Code Online (Sandbox Code Playgroud)

在第二个查询结束时,所以我猜你可以看到问题,如果windows显示的时间比查询要长一些会发生什么.这是应该由事件处理的事情吗?

是否有活动

lastWindow.open(map);
Run Code Online (Sandbox Code Playgroud)

因此,当infowindow完全打开时,它可以附加图像吗?

Jon*_*son 33

InfoWindow对象在将事件domready事件附加(完全加载)到DOM时触发事件事件.您可以在API文档中看到这一点:https://developers.google.com/maps/documentation/javascript/reference#InfoWindow

然后你可以有一个像下面那样的监听器,在加载自己后将内容加载到infoWindow:

var referenceToInfoWindow = new google.maps.InfoWindow({content: 'My info' });

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);
}); 
Run Code Online (Sandbox Code Playgroud)