我在我的网站上使用谷歌地图的api来显示两个位置。谷歌地图在我的本地解决方案中运行得很好,但在我的网站上却没有。我改变了这个消息来源
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"> </script>为了这件事。我又一次改变了这个
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script>用这个..。
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"> </script>它只说了一件事:ReferenceError: google没有定义
有谁知道这个问题吗?
发布于 2012-09-05 15:35:12
由于我的网站使用https作为连接,所以我不能使用http://maps.google.com/maps/api/js?sensor=false。当我调试整个页面时,这个链接是:警告:页面index.html运行不安全的内容。于是,我又在谷歌上搜索了一下,并找到了这个question。因此,造成问题的根本原因是在源部分中没有使用https链接,所以正确的链接将是(对我而言)。
https://maps.google.com/maps/api/js?sensor=false现在一切都很好!
发布于 2012-09-03 18:50:47
这是个旧网址。如果您查看examples from the documentation,几乎所有这些代码都使用:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> 发布于 2019-01-08 10:38:12
对我来说,使用新的Google,这个解决方案很有效:只需从goolge提供的脚本中省略“异步延迟”即可:
<script async defer src="https://maps.googleapis.com/maps/api/js?key={your_key}"></script>至
<script src="https://maps.googleapis.com/maps/api/js?key={your_key}"></script>https://stackoverflow.com/questions/12249136
复制相似问题