Bing Maps incompatibility with MooTools

≡放荡痞女 提交于 2019-12-25 04:47:11

问题


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

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

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

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


回答1:


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 library internally has the dependency to the same method used for loading suplementary library files. `

A workaround would be to remove MooTools specific method:

delete Element.prototype.send; 

Demo: plunker



来源:https://stackoverflow.com/questions/40185594/bing-maps-incompatibility-with-mootools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!