Google Maps - Resource interpreted as Script but transferred with MIME type image/png

匿名 (未验证) 提交于 2019-12-03 08:44:33

问题:

I did some research and I couldn't find a post that was specific to the Google Maps V3 Javascript API, so I'm posting a new question. Please let me know if there is a more appropriate place for this question.

My Issue:

Without touching anything, my website, utilizing the Google Maps V3 Javascript API, started giving me this error:

Resource interpreted as Script but transferred with MIME type image/png  Refused to execute script from 'http://mt1.googleapis.com/vt?pb=!1m4!1m3!1i15!2i9148!3i11958!1m4!1m3!1i15!2…2m1!1e47!12m3!1e37!2m1!1ssmartmaps!4e3&callback=_xdc_._63mj9u&token=110320' because its MIME type ('image/png') is not executable, and strict MIME type checking is enabled.  

I started getting this in Chrome's javascript console completely out of the blue. Could this be related to too many requests to Google Maps? I was doing some tinkering on the map page and refreshing somewhat frequently, but never touched any of the working script dealing with how the map or its tiles are rendered - so I'm very confused.

Has anyone run into this issue and/or know of a solution?

UPDATE As implied in a comment below, this is not an 'ignorable' issue as it is affecting how the map tiles are rendered. Others are beginning to experience this kind of issue as well, as noted in this post. It is also an issue that is affecting other maps I've initiated on other websites (example).

回答1:

I'm had open a issue in google maps and i got the answer:

There is a problem with the address of this api using htttp protocol. Replace with https that will work.

ex: 'https://maps.googleapis.com/maps/api/js?v=3'



回答2:

Basically you may assume that it's a bug that has to be fixed in the API, not on clientside.

What you can try and should do:

In production you should always load the release-version of the API.

Currently you try to load the API-version 3.9.2 which isn't available anymore.

Instead the experimental version has been loaded.

Currently the documentation says that 3.17 is experimental and 3.16 is the release-version, but I think this isn't correct(not updated yet).

run inside the console:

alert(window.google.maps.version)  

...and you'll see what has been loaded

As it seems there has been an update, 3.17 is release and 3.18 experimental(I guess the new 3.18 is the source of the issue)

loading the release-version:

<script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?libraries=geometry&v=3'></script> 


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