javascript - 谷歌地图 API 和 Github 页面

标签 javascript html css google-maps-api-3 github-pages

所以我试图将我的简历放在 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/

相关文章:

javascript - 根据内容改变父div的宽度

javascript - 如何从 firestore 获取数据并在其中获取另一个数据(通过引用)

javascript - 将动态类名传递给 JavaScript 函数

javascript - IntelliJ - Unresolved JavaScript 引用

php - 如何使图标在左侧对齐的中心图标列表小部件(Elementor)?

html - Electron 应用程序中 html 内容的模块化

javascript - 未定义错误: create object with function that returns HTML element

javascript - 添加新按钮到 Tinymce 工具栏 C#

html - 为什么我的包装器在 HTML 中不起作用?

html - 如何让文本在换行符处对称排列