0

我一直在與我們的網站上的谷歌地圖的問題,在IE7和IE8上的第一次加載時發生的問題。我試圖通過結合使用firefox和ie8調試器來處理這個解決方案,但是這很困難(我的老闆也在推動我解決其他問題),因爲JS被縮小了,IE調試器無法做到這一點。 我們有兩個版本的同一網站,一個在irelandhotels.com,另一個在groupbke.young.netaffinity.net。 第一個有500多個標記,開發環境只有5個左右。但是這個問題在兩個站點都會發生。谷歌地圖API(IE7 IE8)堆棧溢出

執行將進入函數yf,然後進入一個帶有3個未命名函數的循環。

我發現一個有趣的文章在這裏對這個問題: http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/

我們的地圖初始化代碼是在這裏: http://groupbke.young.netaffinity.net/bookings/googlemap

我有一些圖片,就不能張貼到目前爲止,也沒有聯繫他們:/

任何幫助將不勝感激。

蓋爾蓋伊

回答

0

如何我過去一直在做這個是這樣的:

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); 
    }); 
} 

另外,(雖然你說這是不是問題),即恨數組或結構哪一端與尾隨逗號。

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, '<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>'], 
    ... 
]; 
+0

感謝您的注意,我已經糾正了這個問題,但它不是什麼導致的問題。 – 2012-07-30 18:44:02

+0

好的,更新我的回答 – duncan 2012-07-30 21:22:30

+0

我的意思是,我仍然收到錯誤。 – 2012-07-31 15:47:51