Javascript 谷歌地图API(IE7 IE8)的堆栈溢出

Javascript 谷歌地图API(IE7 IE8)的堆栈溢出,javascript,google-maps-api-3,internet-explorer-8,internet-explorer-7,stack-overflow,Javascript,Google Maps Api 3,Internet Explorer 8,Internet Explorer 7,Stack Overflow,我一直在与我们网站上的谷歌地图进行斗争,这是IE7和IE8首次加载时出现的问题。我试图通过结合firefox和ie8调试器来解决这个问题,但这相当困难(我的老板也在其他问题上催促我),因为JS已经缩小,IE调试器对此无能为力。 同一个站点有两个版本,一个在irelandhotels.com,另一个在groupbke.young.netaffinity.net。 第一个有500多个标记,开发环境只有5个左右。但是,这两个站点都会出现问题 执行将进入函数yf,然后进入一个包含3个未命名函数的循环 我

我一直在与我们网站上的谷歌地图进行斗争,这是IE7和IE8首次加载时出现的问题。我试图通过结合firefox和ie8调试器来解决这个问题,但这相当困难(我的老板也在其他问题上催促我),因为JS已经缩小,IE调试器对此无能为力。 同一个站点有两个版本,一个在irelandhotels.com,另一个在groupbke.young.netaffinity.net。 第一个有500多个标记,开发环境只有5个左右。但是,这两个站点都会出现问题

执行将进入函数yf,然后进入一个包含3个未命名函数的循环

我在这里找到了一篇关于这个问题的有趣文章:

我们的地图初始化代码如下:

我有一些图片,只是目前无法发布,也无法链接:/

任何帮助都将不胜感激


Gergely过去我总是这样做:

function initialize(mapid) {
    // make this local to your initialize function
    var hoteldata = [
        ['Griffen Hotel S1', 53.27093787103, -6.30448181406804, 'Lorem Ipsum', 1],
        ['Young Testing Hotel - Liège', 53.33932, -6.261427, 'Lorem Ipsum', 4]
    ];

    var myOptions = {
        zoom: 15,  // according to the documentation zoom and center are required when creating instances of the Map class
        center: new google.maps.LatLng(50.820645,-0.137376),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        mapTypeControl: false
    };
    var bounds = new google.maps.LatLngBounds();
    var map = new google.maps.Map(document.getElementById(mapid), myOptions);
    var infowindow = new google.maps.InfoWindow();
    var markers = [];
    var i, latLng, img;

    for (i = 0; i < hoteldata.length; i++) {
        latLng = new google.maps.LatLng(hoteldata[i][1], hoteldata[i][2]);
        bounds.extend(latLng);

        // why not use a switch here?
        img = '/images/hotel-marker.png';
        if (hoteldata[i][4] == 2) {
            img = '/images/country-marker.png';
        }
        if (hoteldata[i][4] == 3) {
            img = '/images/guesthouse-marker.png';
        }
        if (hoteldata[i][4] == 4) {
            img = '/images/hotel-self-marker.png';
        }
        var marker = new google.maps.Marker({
        position: latLng,
        icon: img,
        shadow: '/images/marker-shadow.png'
        });
        markers.push(marker);

        bindInfoWindow(marker, map, infowindow, hoteldata[i][3]);
    }

    map.fitBounds(bounds);
}

function bindInfoWindow(marker, map, infowindow, html) { 
    google.maps.event.addListener(marker, 'click', function() { 
        infowindow.setContent(html); 
        infowindow.open(map, marker); 
    }); 
} 
函数初始化(mapid){
//将此设置为初始化函数的本地设置
var hoteldata=[
['Griffen Hotel S1',53.27093787103,-6.30448181406804,'Lorem Ipsum',1],
[Young Testing Hotel-Liège',53.33932,-6.261427',Lorem Ipsum',4]
];
变量myOptions={
zoom:15,//根据文档,创建Map类的实例时需要缩放和居中
中心:新google.maps.LatLng(50.820645,-0.137376),
mapTypeId:google.maps.mapTypeId.ROADMAP,
mapTypeControl:false
};
var bounds=new google.maps.LatLngBounds();
var map=new google.maps.map(document.getElementById(mapid),myOptions);
var infowindow=new google.maps.infowindow();
var标记=[];
var i、latLng、img;
对于(i=0;i
另外,(尽管你说这不是问题)IE讨厌以逗号结尾的数组或结构

var hoteldata = [
    ['Griffen Hotel S1', 53.27093787103, -6.30448181406804, '<div class="nearby-hotel"> <h1><a href="/hotels/ireland/dublin/dublin/griffen-hotel-s1">Griffen Hotel S1</a></h1> <div class="star-rating-0"></div><div class="clear"></div> <div class="nearby-hotel-image l"> <a href="/hotels/ireland/dublin/dublin/griffen-hotel-s1"><img src="http://groupbke.young.netaffinity.net/images/placeholder-60px.jpg" border="1" class="imagetype1"/></a> </a> </div> <div class="nearby-hotel-description l">  <a class="nearby-hotel-desc" href="/hotels/ireland/dublin/dublin/griffen-hotel-s1">Located in the heart of the city, this charming 100 executive Bedroom hotel is just a minute\'s walk from the main shopping and business districts.      Just step into the reception area and immediately you will know that you are somewhere very special. The beautiful reception area invites you to relax with the daily paper or a soothing drink whilst you contemplate your day.    With sumptuous executive hotel rooms and something for all the family, the Griffen Hotel undoubtedly earns its reputation as one of the cities finest.   </a> <a href="/hotels/ireland/dublin/dublin/griffen-hotel-s1" class="btn-small">Book Now</a> </div> <div class="clear"></div> </div>', ],
    ...
];
var hoteldata=[
[Griffen Hotel S1',53.27093787103,-6.30448181406804',,],
...
];
在第一次关闭之前,移除最后一个]使其看起来像:

var hoteldata = [
    ['Griffen Hotel S1', 53.27093787103, -6.30448181406804, '<div class="nearby-hotel"> <h1><a href="/hotels/ireland/dublin/dublin/griffen-hotel-s1">Griffen Hotel S1</a></h1> <div class="star-rating-0"></div><div class="clear"></div> <div class="nearby-hotel-image l"> <a href="/hotels/ireland/dublin/dublin/griffen-hotel-s1"><img src="http://groupbke.young.netaffinity.net/images/placeholder-60px.jpg" border="1" class="imagetype1"/></a> </a> </div> <div class="nearby-hotel-description l">  <a class="nearby-hotel-desc" href="/hotels/ireland/dublin/dublin/griffen-hotel-s1">Located in the heart of the city, this charming 100 executive Bedroom hotel is just a minute\'s walk from the main shopping and business districts.      Just step into the reception area and immediately you will know that you are somewhere very special. The beautiful reception area invites you to relax with the daily paper or a soothing drink whilst you contemplate your day.    With sumptuous executive hotel rooms and something for all the family, the Griffen Hotel undoubtedly earns its reputation as one of the cities finest.   </a> <a href="/hotels/ireland/dublin/dublin/griffen-hotel-s1" class="btn-small">Book Now</a> </div> <div class="clear"></div> </div>'],
    ...
];
var hoteldata=[
[Griffen Hotel S1',53.27093787103,-6.30448181406804',],
...
];

感谢您的提醒,我已经纠正了这个问题,但这不是问题的原因。我认为问题在于将未命名函数嵌套在循环中-我的解决方案是在循环中引用一个命名函数。更改该函数会有所帮助。仍然会出现stackoverflow错误,但现在它是一个缩放问题。找到此:。这样打开页面就可以很好地工作。但是子页面仍然抛出相同的错误,即使我只调用setCenter或setZoom本身。另外,如果我没有调用任何东西,则映射没有加载,并且我没有收到任何错误。您可以将此作为一个单独的问题,并使用您现在使用的新代码来提问吗?当然,问题在这里:。我想投赞成票,但首先需要一些代表。