Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
谷歌地图:openInfoWindowTabsHtml+;GDownloadUrl(Ajax调用)问题_Ajax_Google Maps - Fatal编程技术网

谷歌地图:openInfoWindowTabsHtml+;GDownloadUrl(Ajax调用)问题

谷歌地图:openInfoWindowTabsHtml+;GDownloadUrl(Ajax调用)问题,ajax,google-maps,Ajax,Google Maps,我面临以下问题。 在谷歌地图上,我想添加带有选项卡的信息窗口,其中的内容是使用GDownloadUrl方法从外部文件加载的。 代码运行得很好,但有两个问题。 a) 我第一次点击一个标记时,什么都没有。我需要点击两次以获得一个信息框。在那之后它工作正常。 b) 当我关闭一个信息框并再次打开它时,选项卡会重复它们自己。每次我重新打开信息框时,这些选项卡都会重复。因此,如果使用下面的代码并打开信息框3次,我会得到6个选项卡(信息、照片、信息、照片、信息、照片)。你知道我做错了什么吗 我还尝试了JQue

我面临以下问题。 在谷歌地图上,我想添加带有选项卡的信息窗口,其中的内容是使用GDownloadUrl方法从外部文件加载的。 代码运行得很好,但有两个问题。 a) 我第一次点击一个标记时,什么都没有。我需要点击两次以获得一个信息框。在那之后它工作正常。 b) 当我关闭一个信息框并再次打开它时,选项卡会重复它们自己。每次我重新打开信息框时,这些选项卡都会重复。因此,如果使用下面的代码并打开信息框3次,我会得到6个选项卡(信息、照片、信息、照片、信息、照片)。你知道我做错了什么吗

我还尝试了JQuery的$.get方法,但结果完全相同

function createREMarker(lat,long,reID)
{
    var reMarker = new GMarker(rePoint,iconRE);
    GEvent.addListener(reMarker, "click", function()
    {
        GDownloadUrl('testcontent.php?reID='+reID+'&what=info', function(data) {
            content1 = data;
        });
        GDownloadUrl('testcontent.php?reID='+reID+'&what=photos', function(data) {
            content2 = data;
        });
        tabs.push(new GInfoWindowTab('Info', '<div id="mapOverlayContent" style="width:375px; height:220px; overflow:auto;">'+content1+'</div>'));
        tabs.push(new GInfoWindowTab('Photos', '<div id="mapOverlayContent" style="width:375px; height:220px; overflow:auto;">'+content2+'</div>'));
        reMarker.openInfoWindowTabsHtml(tabs);
    });
    return reMarker;
};
函数createREMarker(lat、long、reID)
{
var reMarker=新的GMarker(rePoint,iconRE);
addListener(重新标记,“单击”,函数()
{
GDownloadUrl('testcontent.php?reID='+reID+'&what=info',函数(数据){
content1=数据;
});
GDownloadUrl('testcontent.php?reID='+reID+'&what=photos',函数(数据){
content2=数据;
});
tabs.push(新的GInfoWindowTab('Info',''+content1+'');
tabs.push(新的GInfoWindowTab('Photos',''+content2+'');
openInfoWindowTabsHtml(tabs);
});
回报再营销;
};

首先,您使用的是API的v2版本,该版本现在已被正式弃用。对于我维护的站点,我执行以下操作(这是API的v3,使用jQuery):

函数createMarker(点、id、标记选项){
var marker=new google.maps.marker(point,markerOptions);
var Lat=point.Lat();
var Lng=point.Lng();
google.maps.Event.addListener(标记“单击”,函数(){
$.ajax({
键入:“获取”,
url:“/data/specific.xml?id=“+id,
数据类型:“xml”,
成功:函数(xml){
var this_marker=$(xml).find('marker');
变量名称=$(此_标记).attr(“名称”);
详细信息选项卡=详细信息选项卡+“ID:+ID+”
名称:“+Name+”
”; var infowindow=new google.maps.infowindow({ 内容:详细信息选项卡, }); 信息窗口。打开(地图、标记); } }); } 返回标记; }
据我所见,API的v3不再支持选项卡?:(但本例使用jQuery UI中的选项卡:


Thnx。没有想到使用jquery选项卡作为替代。仅供参考:该示例在IE11中被破坏,它显示了3个点而不是选项卡。
function createMarker(point, id, markerOptions) {
    var marker = new google.maps.Marker(point,markerOptions);
    var Lat = point.lat();
    var Lng = point.lng();

    google.maps.Event.addListener(marker, "click", function() {
        $.ajax({
            type: "GET",
            url: "/data/specific.xml?id=" + id,
            dataType: "xml",
            success: function(xml) {
               var this_marker = $(xml).find('marker');
               var name = $(this_marker).attr("name");
               details_tab = details_tab + "ID: " + id + "<br />Name: " + name + "<br />";
               var infowindow = new google.maps.InfoWindow({
                   content: details_tab,
               });
               infowindow.open(map, marker);
            }
        });
    }
    return marker;
}