必应地图与MooTools不兼容 [英] Bing Maps incompatibility with MooTools

查看:100
本文介绍了必应地图与MooTools不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用MooTools的现有项目,我想向其中添加一个Bing Map.但是,我发现MooTools破坏了必应地图.我有点不知如何解决此问题. 此处是显示问题的jsfiddle.如果您在单击运行"按钮时观看控制台,则会看到Bing抛出异常

I have an existing project that uses MooTools that I would like to add a Bing Map to. I've discovered, however, that MooTools breaks Bing Maps. I'm kind of at a loss of how to fix this. Here is a jsfiddle that shows the problem. If you watch your console when you click the Run button, you'll see that Bing throws an exception

Uncaught TypeError: n.open is not a function

如果您随后禁用MooTools,然后再次点击运行,则会在结果窗格中看到该地图.

If you then disable MooTools, and hit run again, you'll see the map appears in the results pane.

我该如何克服?这是bug吗?–是在Bing还是在MooTools中?

How do I get past this? Is this a bug?--in Bing or in MooTools?

我现有的项目使用的是MooTools 1.3.2,但即使在1.6.0中也出现了问题.

The existing project that I have uses MooTools 1.3.2, but the issue shows up even in 1.6.0.

推荐答案

结果 MooTools 中断了Bing Maps API的加载,因为它使用send方法扩展了 Element对象:

Turns out MooTools breaks Bing Maps API loading since it extends Element object with send method:

Element.implement({

    send: function(url){
        var sender = this.get('send');
        sender.send({data: this, url: url || sender.options.url});
        return this;
    }

});

Bing Maps库内部依赖于用于加载补充库文件的相同方法.

Bing Maps library internally has the dependency to the same method used for loading suplementary library files. `

一种解决方法 是删除MooTools特定方法:

A workaround would be to remove MooTools specific method:

delete Element.prototype.send; 

演示:吉他手

这篇关于必应地图与MooTools不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆