您可以通过 Google AJAX API 加载器加载 Google Maps API v3
前段时间我使用常规方法加载Google Maps API,如下所示:
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=abcdefg&sensor=true">
后来我改用Google AJAX API来加载Google Maps API。这是因为我网站上的几个“小部件”需要 Google Ajax API 加载器,因此我选择保持一致并使用 AJAX API 来加载 Google 地图:
<script type="text/javascript" src="http://www.google.com/jsapi?key=abcdef"></script>
<script type="text/javascript">
google.load("maps", "2", {"other_params": "sensor=true"});
</script>
现在我终于决定使用 Google Maps API v3,< a href="http://code.google.com/apis/loader/index.html#AvailableAPIs" rel="noreferrer">此页面未在可用版本列表中列出 API v3。 API v3 文档中的示例均未展示 AJAX API 的使用。是否可以(并支持)通过 AJAX API 加载器加载 Google Maps API v3?
Some time ago I used the regular method of loading Google Maps API like this:
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=abcdefg&sensor=true">
Later I switched to Google AJAX APIs to load Google Maps API. This was because a couple of "widgets" on my website needed the Google Ajax API loader so I chose to be consistent and used the AJAX APIs to load Google Maps as well:
<script type="text/javascript" src="http://www.google.com/jsapi?key=abcdef"></script>
<script type="text/javascript">
google.load("maps", "2", {"other_params": "sensor=true"});
</script>
Now that I have finally decided to use Google Maps API v3, this page does not list API v3 in the available version list. None of the examples on API v3 documentation show the use of AJAX APIs as well. Is is possible (and supported) to load Google Maps API v3 via AJAX API loader?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它没有记录,但它有效。
[编辑]
文档现在要求使用 API 密钥,该密钥作为“key”参数传递给加载程序。我已删除“sensor=false”作为参数,因为现在明确不需要它,并且在提供时会引发警告。
It's undocumented, but it works.
[EDIT]
The documentation now requires the use of an API key that is passed to the loader as a "key" parameter. I've removed 'sensor=false' as a parameter because it is now explicitly not required and throws a warning when provided.
这个例子完美运行。
this example work perfectly.