Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

javascript - Google maps doesn't work in Internet Explorer 11

I call my HTML with googlemaps from another application by window.open (javascript). The html page open, but dont works (any action fails), i just can see the map. After i do CTRL + f5 works... I need this working in the first call... someone can help me?

html:

    <html>
    <body>

    <h1>Prisma3 x Google Maps</h1>

    <div id="googleMap" style="width:100%;height:400px;"></div>

    <script>

    function myMap() {

    var map = new google.maps.Map(document.getElementById('googleMap'), {
        zoom: 3,
        center: {lat: 0, lng: -180},
        mapTypeId: 'terrain'
    });

    var flightPlanCoordinates = [
        {lat: 37.772, lng: -122.214},
        {lat: 21.291, lng: -157.821},
        {lat: -18.142, lng: 178.431},
        {lat: -27.467, lng: 153.027}
    ];

    var flightPath = new google.maps.Polyline({
        path: flightPlanCoordinates,
        geodesic: true,
        strokeColor: '#FF0000',
        strokeOpacity: 1.0,
        strokeWeight: 2
    });

    flightPath.setMap(map);
}

    </script>
    <script src="https://maps.googleapis.com/maps/api/js?
    key=AIzaSyC7vePTtjVs90u3kKlOMYP-UtyISm9F56M&callback=myMap"></script>
    </body>
    </html>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have replaced your key with my own and your code(with the javascript at the bottom) works on both Firefox and Internet Explorer.

I had a similar problem recently and below was my solution:

1.0 Asuming you are already logged-in to Gmail, visit https://console.developers.google.com

2.0 You will land at API Manager

3.0 Under Google Maps API, choose Google Maps JavaScript API

4.0 At Google Maps JavaScript API, there is a link at the top named ENABLE

5.0 Click it to enable or activate the API.

Hope it helps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...