简体   繁体   中英

Loading google maps api with libraries

I'm trying to load both the main api and a library (Places) into my web application. According to the documentation, I'm supposed to load the Places library with:

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

But when I use this in combination with my script tag to load the main api, it gives me an error that I'm loading the api twice. How could I load both in the same script tag?

Since you've specified the places in the libraries param, you only need that one script. According to the docs :

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM