Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading multiple maps libraries with javascript

I am trying to load both the maps library and the places library with javascript so I can embed a map into my page, use google.maps.geometry.spherical functions and make places search requests but I'm having trouble loading all 3 libraries. At the moment I am importing:

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

But I get the errors:

syntax error [Break On This Error]     ...gs4d .gbmac,.gbes#gbg4 #gbgs4d .gbmac{margin:34px 0 0}.gbemi#gb #gbgs4d .gbmac,....  maps?k...hrkDAmw (line 1)  GClientGeocoder is not defined [Break On This Error]     var geocoder = new GClientGeocoder(); 

Where am I going wrong?

Thanks a lot.

like image 847
user1229498 Avatar asked Mar 20 '12 11:03

user1229498


People also ask

How do I add multiple libraries to Google Maps API?

You can load additional libraries by specifying a libraries parameter in the bootstrap request, and supplying the name of the library or libraries. You can specify multiple libraries as a comma-separated list. You then access the libraries via the google. maps.

Is JavaScript Google Maps API free?

The Maps JavaScript API uses a pay-as-you-go pricing model. Maps JavaScript API requests generate calls to two different SKUs depending on the type of request: map loads or panoramas.

Is Google Maps API a library?

A library for using arbitrary DOM elements as map markers in the Google Maps JavaScript API v3. This library enables developers to easily build store locator-type applications using the Google Maps JavaScript API v3.


1 Answers

The first script doesn't point to a javascript, this will try to load the maps-homepage as a script(of course this will fail).

There is no need to include multiple scripts, simply use:

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

This will load the maps-API(V3) and includes the places+geometry-libraries

https://developers.google.com/maps/documentation/javascript/libraries?hl=en

However, as Colin said, this looks like V2-code.

like image 176
Dr.Molle Avatar answered Sep 28 '22 10:09

Dr.Molle