Reputation: 13511
I have create a script in WordPress that load all of my JavaScript files, combine and compress them. Among my JavaScript files I have use and the folloign JavaScript file :
http://maps.googleapis.com/maps/api/js?sensor=false
While my script working good, the Google Maps loaded JavaScript file looks like is not running in order to load all the external JavaScript files from Google.
The Google Map file is in the very top of my produced JavaScript file after the combination and the compression, and the content of it are the following :
window.google = window.google||{};
google.maps = google.maps||{};
(
function()
{
function getScript(src)
{
document.write('<'+'script src="'+src+'"'+' type="text/javascript"><'+'/script>');
}
var modules = google.maps.modules = {};
google.maps.__gjsload__ = function(name, text)
{
modules[name]=text;
};
google.maps.Load = function(apiLoad)
{
delete google.maps.Load;
apiLoad(
[
null,
[
[
[
"http://mt0.googleapis.com/vt?lyrs=m@183000000\u0026src=api\u0026hl=en-US\u0026",
"http://mt1.googleapis.com/vt?lyrs=m@183000000\u0026src=api\u0026hl=en-US\u0026"],
...
DATA
...
null,
null,
0,
"http://khm.googleapis.com/mz?v=115\u0026",
null,
"https://earthbuilder.google.com",
"https://earthbuilder.googleapis.com"
],
loadScriptTime
);
};
var loadScriptTime = (new Date).getTime();
getScript(
"http://maps.gstatic.com/intl/en_us/mapfiles/api-3/9/13b/main.js"
);
}
)();
The above content is the same with the one I have if I go to URL http://maps.googleapis.com/maps/api/js?sensor=false directly by my web browser.
The broblem now is, that while I get that data corectly, the google mas object I get in my console is as follow:
console.log(google);
Object
maps: Object
Load: function (apiLoad)
{
delete google.maps.Load;
...
data
...
}
__gjsload__: function(name, text)
{
modules[name] = text;
}
modules: Object
__proto__: Object
__proto__: Object
and for the following I am getting :
console.log(google.maps.LatLng);
undefined
Upvotes: 2
Views: 3544
Reputation: 14411
The Google Maps API Team has specific code that disallows you from copying the main script locally. In particular, that code "expires" every so many hours. You cannot combine the Google Maps API scripts in with your other scripts.
Upvotes: 3