Google Maps compatibility IE11 not working because of polyfills.js

99封情书 提交于 2019-12-05 04:15:22

问题


My app website is not working fine on IE11.

The website is not loading, it gives me a blank page

This is the error thrown on IE11 :

SCRIPT5005: String expected
js (26,286)

SCRIPT5022: Exception thrown and not caught.
polyfills.js (3234,3)

I'm enclosing the screen capture on on the console

I have included the API in my index.html like this :

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>

It should include googlemaps after my polyfills.js, but I'm not sure on how to do that

I've tried to use agm-map, and others solutions but so far, nothing is working.


回答1:


You could add the Google Maps script to the ngOnInit() method instead of in the tag.

let googleMapsScript = document.createElement('script')
googleMapsScript.setAttribute('src', 'https://maps.google.com/maps/api/js?v=3.38&key=YOURGOOGLEMAPSAPIKEY&libraries=places')
document.head.appendChild(googleMapsScript)

This will load the Google Maps script after the main JS for the application is loaded. I don't use Angular but a similar approach works well in VueJS.




回答2:


I had the same issue. Not Angular but same issue.

I changed the following:

<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places,geometry"></script>

to

<script async defer src="https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places,geometry"></script>



来源:https://stackoverflow.com/questions/57167124/google-maps-compatibility-ie11-not-working-because-of-polyfills-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!