Google Maps API GeoJSON不适用于IE 11,但可在Chrome中使用 [英] Google Maps API GeoJSON not working with IE 11, but works in Chrome

查看:93
本文介绍了Google Maps API GeoJSON不适用于IE 11,但可在Chrome中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个google地图,该地图从Visual Studio 2013中的localhost上运行的GeoJSON文件加载标记.它也以chrome(来自IIS服务器)运行,但不会在IE版本11中运行.该地图显示了,但是JSON文件中的标记不包含.为什么在IIS 8上的Chrome和VS中的IE 11上不能在Chrome中工作,而在IIS 8上的IE 11上却不能工作?

I have a google map that loads markers from a GeoJSON file that runs on localhost in Visual Studio 2013. It also runs in chrome (from an IIS server) but will not run in IE version 11. The map shows up, but the markers from the JSON file do not. Why would this work in Chrome on IIS 8, and IE 11 through VS, but not IE 11 on IIS 8?

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

IE中的

推荐答案

兼容性视图阻止了geoJSON文件的加载. 我放

Compatibility view in IE prevented the loading of the geoJSON file. I put

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

,它已解决了该问题.

at the top of the page and it solved the issue.

非常感谢geocodezip在上面的评论中向我指出了正确的方向.

这篇关于Google Maps API GeoJSON不适用于IE 11,但可在Chrome中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆