我们有一个嵌入Google Maps API v3的页面,最近(今天?)缩放控件和地图背景控件丢失了。未对代码进行任何更改。当我们禁用mootools.js时,控件会返回。谷歌地图API v3最近是否发生了与mootoolsjavascript不兼容的变化,这可能会导致控件消失?
问题是由Mootools的旧版本引起的。
你能试着使用最新版本的mootools吗?
我在构建ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0时使用了mootools 1.4.5,但它不起作用如果我将mootools 1.4.5与构建74e34796f5f76640cdb98853004650aea1499d69一起使用,它就可以工作了。
错误在Function.implement和方法绑定中。
首次构建:
bind: function(bind, args){
var self = this;
if (args != null) args = Array.from(args);
return function(){
return self.apply(bind, args || arguments);
};
},
第二次构建:
/*<!ES5-bind>*/
bind: function(that){
var self = this,
args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
F = function(){};
var bound = function(){
var context = that, length = arguments.length;
if (this instanceof bound){
F.prototype = self.prototype;
context = new F;
}
var result = (!args && !length)
? self.call(context)
: self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
return context == that ? result : context;
};
return bound;
},
第二个版本对错误有更多的保护。
我认为Mootools破坏了Gmaps的部分全局代码,可能是事件处理程序。
在Mootools-core.js之后加载Google Maps API Javascript,这对我有效
我今天用Gmaps API V3、Mootools 1.4和Mootools 1.5测试了这一点。
(对不起,我不会说英语:D)
这种情况以前在我身上发生过几次,所有的突然控制都很有趣,一天后就会自动修复。我搞砸了bootstrap,而不是你的mootools。
我觉得这很有帮助在你的样式表中添加这个:
#mapDiv img{ max-width: none; }