谷歌地图API GeoJSON不适用于IE 11,但适用于Chrome
Google Maps API GeoJSON not working with IE 11, but works in Chrome
我有一个谷歌地图,它从Visual Studio 2013中本地主机上运行的GeoJSON文件中加载标记。它也在chrome中运行(来自IIS服务器),但不会在IE版本11中运行。映射会显示,但JSON文件中的标记不会显示。为什么这在IIS 8上的Chrome和通过VS的IE 11中都能工作,而在IIS 8的IE 11中却不能工作?
var map;
var infowindow = new google.maps.InfoWindow({ });
function initialize() {
map = new google.maps.Map(document.getElementById('googleMap'), {
center: new google.maps.LatLng(15.508742, -0.120850),
zoom: 2,
mapTypeId: google.maps.MapTypeId.HYBRID,
scrollwheel: false
});
google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});
// Load a GeoJSON from the same server as our demo.
map.data.loadGeoJson('locations.json');
// Set event listener for each feature.
map.data.addListener('click', function (event) {
infowindow.setContent("<div> " + event.feature.getProperty('city') + " " + event.feature.getProperty('date') + "<br>" + event.feature.getProperty('course') + "<br>Sponsored by: " + event.feature.getProperty('sponsor') + "<br>" + "<a href=" + "/Training.aspx" + ">Click here to Register</a>" + "</div>");
infowindow.setPosition(event.latLng);
infowindow.setOptions({ pixelOffset: new google.maps.Size(0, -34) });
infowindow.open(map);
});
map.data.addListener('mouseover', function (event) {
//infowindow.setContent("<div class='"map_info_box'" > " + event.feature.getProperty('city') + " " + event.feature.getProperty('date') + "<br>" + event.feature.getProperty('course') + "<br>Sponsored by: " + event.feature.getProperty('sponsor') + "<br>" + "<a href=" + "/Training.aspx" + ">Click here to Register</a>" + "</div>");
infowindow.setContent("<div> " + event.feature.getProperty('city') + " " + event.feature.getProperty('date') + "<br>" + event.feature.getProperty('course') + "<br>Sponsored by: " + event.feature.getProperty('sponsor') + "<br>" + "<a href=" + "/Training.aspx" + ">Click here to Register</a>" + "</div>");
infowindow.setPosition(event.latLng);
infowindow.setOptions({ pixelOffset: new google.maps.Size(0, -34) });
infowindow.open(map);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
在页面顶部,它解决了问题。
非常感谢geocodezip,他在上面的评论中为我指明了正确的方向
相关文章:
- JQueryhide()不适用于Mozzilla,但适用于Chrome
- Regex不适用于Firefox,但适用于Chrome
- 关闭当前选项卡并打开一个新的-仅适用于Chrome
- 向下滚动时隐藏菜单,向上滚动时显示,适用于Chrome,不适用于Safari(手机)
- Mozilla并没有完美地执行这段代码,尽管它适用于Chrome和IE
- Angularjs ng-options 问题仅适用于 Chrome 浏览器
- 支持 JavaScript 的检查例程适用于 Chrome/Opera/IE,但不适用于 Firefox/Safari
- javascript单选按钮验证,适用于chrome,不适用于IE
- getElementsByTagName未保存(仅适用于chrome)
- 在bookmarklet中使用@import和@font face(适用于Chrome,但不适用于Firefox)
- Ajax成功回调仅适用于Chrome
- ScrollTop适用于Chrome和Edge,但不适用于Firefox
- jQuery适用于Chrome、Firefox、IE,但不适用于iPhone
- minlength仅适用于Chrome
- 自动完成功能适用于Chrome,但不适用于IE
- Javascript仅适用于Chrome
- formatDate JavaScript 函数仅适用于 Chrome
- Javascript String to Date适用于Chrome,而不是FF或Safari
- 文件上传代码适用于Chrome和Mozilla,但不适用于IE 8,9
- 地理编码器仅适用于chrome,不适用于Firefox / IE / android