我正在尝试将主api和库(Places)加载到我的Web应用程序中。根据文档,我应该加载Places库:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
但是当我结合我的脚本标签使用它来加载主api时,它给了我一个错误,我正在加载api两次。我怎么能在同一个脚本标签中加载它们?
答案 0 :(得分:3)
由于您已在places
参数中指定了libraries
,因此您只需要一个脚本。根据{{3}}:
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.