Cristiano
Cristiano

Reputation: 2909

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?

Upvotes: 1

Views: 1003

Answers (1)

Cianan Sims
Cianan Sims

Reputation: 3429

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.

Upvotes: 3

Related Questions