所以我试图将我的简历放在 git 页面上,它包含谷歌地图 API,当我在没有任何服务器的情况下打开文件时它运行良好。但是当我在我的 git hub 页面上运行它时,它会抛出错误:
Mixed Content: The page at 'https://jcook894.github.io/My_Resume/' was loaded over HTTPS, but requested an insecure script "'http://maps.googleapis.com/maps/api/js?libraries=places&key=XXXXXXXXXXXXXXXXXXXXXX'". This request has been blocked; the content must be served over HTTPS.
然后是这个错误:
helper.js:121 Uncaught ReferenceError: google is not defined at initializeMap
是不是我的 api key 有问题导致无法通过?
最佳答案
要解决混合内容的问题,只需通过 https 加载谷歌地图:
https://maps.googleapis.com/maps/api/js?libraries=places&key=XXXXXX
有关 GitHub 页面和混合内容的更多信息,请参阅 the documentation .
关于javascript - 谷歌地图 API 和 Github 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41583891/