1

我正在尝试将主 API 和库(Places)加载到我的 Web 应用程序中。根据文档,我应该加载 Places 库:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

但是当我将它与我的脚本标签结合使用来加载主 api 时,它给了我一个错误,我正在加载 api 两次。我怎么能在同一个脚本标签中加载两者?

4

1 回答 1

3

由于您已经placeslibraries参数中指定了,您只需要一个脚本。根据文档

The JavaScript code for the Maps API is loaded via a bootstrap URL of the 
form http://maps.googleapis.com/maps/api/js.
This bootstrap request loads all of the main Javascript objects and symbols 
for use in the Maps API. Some Maps API features are also available in 
self-contained libraries which are not loaded unless you specifically 
request them.
于 2013-03-27T19:18:29.803 回答