我已经在WordPress中创建了一个脚本,该脚本加载我所有的JavaScript文件,并对它们进行合并和压缩。在我使用的JavaScript文件和下面的JavaScript文件中:
http://maps.googleapis.com/maps/api/js?sensor=false虽然我的脚本运行良好,但是为了从谷歌加载所有外部JavaScript文件,Google Maps加载的JavaScript文件看起来并没有运行。
经过合并和压缩后,Google Map文件位于我生成的JavaScript文件的最顶部,其内容如下:
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"
);
}
)();上面的内容和我用浏览器直接访问URL http://maps.googleapis.com/maps/api/js?sensor=false的内容一样。
现在问题是,虽然我正确地获取了数据,但我在控制台中获得的google mas对象如下所示:
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对于以下内容,我将得到:
console.log(google.maps.LatLng);
undefined发布于 2012-08-28 04:37:38
Google Maps API团队有一些特定的代码,禁止您在本地复制主脚本。特别是,代码每隔几个小时就会“过期”一次。您不能将Google Maps API脚本与其他脚本组合在一起。
https://stackoverflow.com/questions/12108014
复制相似问题