Search code examples
mootoolsbing-maps

Bing Maps incompatibility with MooTools


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.


Solution

  • 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