none
RequireJS, domReady and AJAX v8 RRS feed

  • Question

  • I have a fairly complex map application using version 7 of the AJAX library. Based on Ricky's presentation I tried just swapping the original V7 script reference to the new V8 located at http://bing.com/api/maps/mapcontrol

    I started getting weird errors and thought that it had to do with the use of requireJS in my application (each map layer is a requireJS module).

    I created a simple requireJS template in JSfiddle - just a single module with jQuery and the domReady plugin. Everything worked great until I add a reference to the V8 map module.

    Here's what I've done:

    This is using V7 (notice the external resource) everything works fine: http://jsfiddle.net/pa5tgoek/2/

    This is exactly the same as the previous, except the external resource has been switched to V8: http://jsfiddle.net/pa5tgoek/3/

    Notice that I'm now getting the error: Mismatched anonymous define() module: function (){return SVG}

    Fair enough, rather than referencing the map library alongside requireJS, I'll do it inside of requireJS like so: http://jsfiddle.net/pa5tgoek/4/

    Now I get an error when trying to load the map "n is not a constructor". At this point I'm at a loss as to what is happening, any advice?

    Monday, April 4, 2016 10:20 PM

Answers

  • I'll the dev team take a look at this to see if they know what the issue is. I do know others have had issues with require JS before and Bing Maps V7 as it accesses the DOM and some browsers limit the ability of JavaScript files that are dynamically loaded in from different domains.

    Also worth noting that the Bing Maps V8 control also has async loading functionality: https://msdn.microsoft.com/en-us/library/mt712557.aspx

    Update: I talked to our dev team about this and it sounds like they are already aware of the requireJS issue. Apparently there is some conflicts between the libraries that is causing an issue. The team is investigating to how they can fix this.


    http://rbrundritt.wordpress.com


    Monday, April 4, 2016 11:04 PM
  • I've updated the sample by doing an async loading of maps. Hope this should fix the issue

    http://jsfiddle.net/pa5tgoek/6/


    Tuesday, April 5, 2016 7:00 PM
  • To help anyone that maybe experiencing the same issue in IE11, I resolved the "Promise is undefined" issue by using a poly-fill called es6-promise (https://github.com/stefanpenner/es6-promise)

    The below code block is working IE and Chrome now.

    require('es6-promise').polyfill();
    require(['async!http://www.bing.com/api/maps/mapcontrol!callback'], function(){
        var map = new Microsoft.Maps.Map(document.getElementById(uniqid), { credentials: 'Your Bing Maps Key' });
        var color = new Microsoft.Maps.Color(255, 0, 56, 107);
    });

    Wednesday, May 25, 2016 9:04 AM

All replies

  • I'll the dev team take a look at this to see if they know what the issue is. I do know others have had issues with require JS before and Bing Maps V7 as it accesses the DOM and some browsers limit the ability of JavaScript files that are dynamically loaded in from different domains.

    Also worth noting that the Bing Maps V8 control also has async loading functionality: https://msdn.microsoft.com/en-us/library/mt712557.aspx

    Update: I talked to our dev team about this and it sounds like they are already aware of the requireJS issue. Apparently there is some conflicts between the libraries that is causing an issue. The team is investigating to how they can fix this.


    http://rbrundritt.wordpress.com


    Monday, April 4, 2016 11:04 PM
  • I've updated the sample by doing an async loading of maps. Hope this should fix the issue

    http://jsfiddle.net/pa5tgoek/6/


    Tuesday, April 5, 2016 7:00 PM
  • I've updated the sample by doing an async loading of maps. Hope this should fix the issue

    http://jsfiddle.net/pa5tgoek/6/


    This works fine in Chrome but fails in IE11.

    I consistently get a "'Promise' is undefined" error when trying to load a very basic map.

    Tuesday, May 24, 2016 9:52 PM
  • To help anyone that maybe experiencing the same issue in IE11, I resolved the "Promise is undefined" issue by using a poly-fill called es6-promise (https://github.com/stefanpenner/es6-promise)

    The below code block is working IE and Chrome now.

    require('es6-promise').polyfill();
    require(['async!http://www.bing.com/api/maps/mapcontrol!callback'], function(){
        var map = new Microsoft.Maps.Map(document.getElementById(uniqid), { credentials: 'Your Bing Maps Key' });
        var color = new Microsoft.Maps.Color(255, 0, 56, 107);
    });

    Wednesday, May 25, 2016 9:04 AM
  • I talked to our dev team about this and it sounds like they are already aware of the requireJS issue. Apparently there is some conflicts between the libraries that is causing an issue. The team is investigating to how they can fix this.

    Hi Ricky, will there be a fix for this in the next release?
    Wednesday, July 27, 2016 11:07 PM
  • I'm fairly certain the dev team made some fixes for this back in June. This should be in the experimental branch.

    [Blog] [twitter] [LinkedIn]

    Thursday, July 28, 2016 12:42 AM
  • Does anyone know if this issue was resolved?  With the planned retirement of v7 coming in June, we'll need to revisit integrating v8 which we delayed after running into RequireJS incompatibilities.  It's not mentioned at all on the "What's new" area of MSDN for Bing Maps. 

    Thanks!

    Thursday, February 2, 2017 9:39 PM
  • This issue was actually put on hold as there are a couple of simple workarounds proposed in this and a couple other threads on the forums. Also the usage of IE11 across the platform is dropping rather quickly.

    That said, this issue is still in our bug system. We haven't had any licensed customers report this issue to the Bing Maps Enterprise support team, so it is considered lower priority at the moment. If you license Bing Maps, be sure to report this to the support team so they can not only log and track it from their end, but also help increase its priority.


    [Blog] [twitter] [LinkedIn]

    Friday, February 3, 2017 8:56 PM
  • This issue was actually put on hold as there are a couple of simple workarounds proposed in this and a couple other threads on the forums. Also the usage of IE11 across the platform is dropping rather quickly.

    That said, this issue is still in our bug system. We haven't had any licensed customers report this issue to the Bing Maps Enterprise support team, so it is considered lower priority at the moment. If you license Bing Maps, be sure to report this to the support team so they can not only log and track it from their end, but also help increase its priority.

    Thanks, Ricky!  We are an enterprise customer, so we'll try the workarounds and open a ticket if we can't resolve it. 

    Tuesday, February 7, 2017 6:24 PM