3

我是我大学的网络开发人员,目前正在研究我们的地图。该网站可以在这里找到。单击标题时,每个标题下都会出现图钉,当单击图钉时(在地图上或侧边栏中),应该会弹出一个信息窗口,其中包含有关该位置的简短片段,通常旁边有一张照片。不幸的是,在过去的两个月里,信息窗口都停止了显示。我已经尝试确保我们的 jquery 是最新的,并运行我们制作的自定义 javascript 以查看是否有任何重大更改(我可以说最好,没有)。我想知道 Google Maps API 最近是否有任何可能破坏这一点的更新。我正在逐步执行脚本,试图找出潜在的问题区域,但结果很枯燥。

(编辑)我会把相关代码贴到infowindows上,不然大家都头疼。

for (var i in data.d.Buildings) {
    var color = categories[4].Color.substring(1);
    var myLatLng = new google.maps.LatLng(data.d.Buildings[i].Latitude, data.d.Buildings[i].Longitude);
    var image = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' + data.d.Buildings[i].LegendKey + '|' + color + '|ffffff';
    categoryItems['search'][i].marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image,
        pushpinInfo: data.d.Buildings[i]
    });

    google.maps.event.addListener(categoryItems['search'][i].marker, 'click', function () {
        infowindow.content = '<div class="bubble"><h3>' + this.pushpinInfo.Name + '</h3>' + (this.pushpinInfo.ImageUrl != null ? '<img src="' + this.pushpinInfo.ImageUrl + '" alt="' + this.pushpinInfo.Acronym + '" />' : '') + this.pushpinInfo.Description + '</div>';
        infowindow.open(map, this);
    });

    addPushpinToMenu(categoryItems['search'][i], 'search', image);
    count++;
}

    if (data.d.ParkingLots[i].Name != null && data.d.ParkingLots[i].Name != "") {
        google.maps.event.addListener(categoryItems['search'][count].marker, 'click', function () {
            infowindow.content = '<div class="bubble">' + (this.pushpinInfo.Name != null ? '<h3>' + this.pushpinInfo.Name + '</h3>' : '') + (this.pushpinInfo.Description != null ? this.pushpinInfo.Description : '') + '</div>';
            infowindow.setPosition(this.centerLatLng);
            infowindow.open(map);
        });
    }

    google.maps.event.addListener(categoryItems['search'][count].marker, 'click', function () {
        infowindow.content = '<div class="bubble"><h3>' + this.pushpinInfo.Name + '</h3>' + (this.pushpinInfo.ImageUrl != null ? '<img src="' + this.pushpinInfo.ImageUrl + '" alt="' + this.pushpinInfo.Acronym + '" />' : '') + this.pushpinInfo.Description + '</div>';
        infowindow.open(map, this);
    });

        if (data.d[i].ParkingLots[a].Name != null && data.d[i].ParkingLots[a].Name != "") {
            google.maps.event.addListener(categoryItems[6][i].ParkingLots[a].marker, 'click', function () {
                infowindow.content = '<div class="bubble">' + (this.pushpinInfo.Name != null ? '<h3>' + this.pushpinInfo.Name + '</h3>' : '') + (this.pushpinInfo.Description != null ? this.pushpinInfo.Description : '') + '</div>';
                infowindow.setPosition(this.centerLatLng);
                infowindow.open(map);
            });
        }

    google.maps.event.addListener(categoryItems[data.d[0].TypeID][i].marker, 'click', function () {
        infowindow.content = '<div class="bubble"><h3>' + this.pushpinInfo.Name + '</h3>' + (this.pushpinInfo.ImageUrl != null ? '<img src="' + this.pushpinInfo.ImageUrl + '" alt="' + this.pushpinInfo.Name + '" />' : '') + this.pushpinInfo.Description + '</div>';
        infowindow.open(map, this);
    });
4

1 回答 1

2

该问题与 jQuery 版本无关,是 Maps-API 版本破坏了它(自 3.10 起)

您直接设置 infoWindows 的内容属性,自 3.10 以来似乎失败了。

您可以修复脚本(setContent()改用)或指定 API 版本:

https://maps.googleapis.com/maps/api/js?v=3.9&sensor=false 

(但我建议修复它)

于 2013-01-26T17:41:48.747 回答