Google地图API(IE7 IE8)的堆栈溢出
stack overflow with Google maps API (IE7 IE8)
我一直在与我们网站上的谷歌地图问题作斗争,该问题在IE7和IE8上首次加载时发生。我试图通过结合firefox和ie8调试器来处理这个解决方案,但这很困难(我的老板也在其他问题上督促我),因为JS被缩小了,IE调试器对此无能为力。同一个网站有两个版本,一个在irelandhotels.com上,另一个在groupbke.young.netaffinity.net上。第一个有500多个标记,开发环境只有5个左右。然而,这两个站点都会出现问题。
执行将进入函数yf,然后进入一个包含3个未命名函数的循环。
我在这里找到了一篇关于这个问题的有趣文章:http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/
我们的地图初始化代码如下:http://groupbke.young.netaffinity.net/bookings/googlemap
我有一些图片,只是到目前为止无法发布,也没有它们的链接:/
如有任何帮助,我们将不胜感激。
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);
});
}
此外,(尽管你说这不是问题所在)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, '<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>'],
...
];
相关文章:
- ember.js:转换到相同的路由会产生堆栈溢出问题
- Angular ngRoute导致无限循环和堆栈溢出
- 使用 React Native 和 Redux 热重载化简器时堆栈溢出
- 为 getter 提供默认值,而不会在 Angular 2 模型类中导致堆栈溢出
- Google地图API(IE7 IE8)的堆栈溢出
- 如何逐个执行url请求而不导致堆栈溢出?(Node.JS)
- 第0行出现堆栈溢出
- 使用setTimeout避免堆栈溢出
- jQuery.extend 抛出带有自引用的堆栈溢出异常
- JQuery 验证 - 太多的递归 - 堆栈溢出
- 服务现在堆栈溢出错误
- 在 Extjs 4.2 中创建工具栏,它应该喜欢堆栈溢出工具栏
- 堆栈溢出如何创建模式对话框窗口
- 绘制图像时JavaScript堆栈溢出
- 如何添加类似于堆栈溢出系统的标签文本输入系统
- 为什么我的jQuery函数在IE 8中导致“堆栈溢出”错误
- 堆栈溢出技术推送消息
- 投票箭头 像 堆栈溢出 使用引导程序,如何减小字形图标项的大小并使它们更紧密
- 有人可以向我解释为什么我对此出现堆栈溢出
- 模拟堆栈溢出平滑投票操作