none
Bing mapcontrol API giving error 'n.open' RRS feed

  • Question

  • We are trying to implement the bing map on our application. On home page the map is working fine. But when i go to inner page it using the same code and i'm calling 

    if ("undefined" === typeof Microsoft) {
        alert(" in fusion_map_init");
        $.getScript('https://www.bing.com/api/maps/mapcontrol?callback=fusion_map_update', false);
      }

    this line is calling the mapcontrol and i'm gettign error at 

    n.open("GET",t,!0) line in https://www.bing.com/mapspreview/sdkrelease/mapcontrol?callback=fusion_map_update&_=1495628299449

    This code works at one page but giving error at another page.Any ideas?


    • Edited by akash.shah Wednesday, May 24, 2017 1:02 PM
    Wednesday, May 24, 2017 1:00 PM

Answers

  • Haven't seen this before. Could be a number possible issues. On your main page, do you see this error if you press refresh? If so, it could be an issue where caching of the map control is loading it before your callback is loaded in the page. In this case, reorder your scripts so that the function_map_update function is loaded into the page before the getScript function is called. 

    Another possible issue is if your application requires a content security policy. If it does, then you need to allow the bing.com and virtualearth.net domains. For example: 

    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline' https://*.bing.com https://*.virtualearth.net; style-src 'self' 'unsafe-inline' https://*.bing.com https://*.virtualearth.net; media-src *">




    [Blog] [twitter] [LinkedIn]

    Wednesday, May 24, 2017 4:36 PM
  • Can you try loading the map script using a standard script tag and see if that makes a difference. It looks like you are using  the jQuery getScript tag. The Bing Maps control loads a small javascript file which then loads all the resources it needs (javascript and css files). Using the getScript function may be causes a security issue as this would dynamically load the initial script which wouldn't let that script from loading the additional resources.

    [Blog] [twitter] [LinkedIn]

    Monday, June 5, 2017 4:08 PM

All replies

  • Haven't seen this before. Could be a number possible issues. On your main page, do you see this error if you press refresh? If so, it could be an issue where caching of the map control is loading it before your callback is loaded in the page. In this case, reorder your scripts so that the function_map_update function is loaded into the page before the getScript function is called. 

    Another possible issue is if your application requires a content security policy. If it does, then you need to allow the bing.com and virtualearth.net domains. For example: 

    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline' https://*.bing.com https://*.virtualearth.net; style-src 'self' 'unsafe-inline' https://*.bing.com https://*.virtualearth.net; media-src *">




    [Blog] [twitter] [LinkedIn]

    Wednesday, May 24, 2017 4:36 PM
  • It's showing error in following linke

    s = function() {
        function n(n, t, i) {
            var u = {
                _onstatechange: function() {
                    if (i) {
                        if (!this.$done && (!n.readyState || /loaded|complete/.test(n.readyState)))
                            if (this.$done = !0, n.patch && n.patch(), n.async || !Microsoft.Maps.GlobalConfig.isMapsVertical) u.oncomplete(undefined);
                            else setTimeout(u.oncomplete, 250)
                    } else if (n.readyState === 4)
                        if (n.status === 200) u.oncomplete(n.responseText);
                        else u.onerror(n.status)
                },
                send: function(i) {
                    n.send ? (n.open("GET", t, !0), n.send("")) : (i !== "css" && i !== "Stylesheet" ? n.src = t : n.href = t, Dragonfly.LogData("createReq - send " + t), Dragonfly.LogResourceOrder(t), r.appendChild(n))
                },
                onerror: function() {},
                oncomplete: function() {},
                stateObject: {}
            };
            return u
        }


    It's showing error at 

     send: function(i) {
                    n.send ? (n.open("GET", t, !0), n.send("")) : (i !== "css" && i !== "Stylesheet" ? n.src = t : n.href = t, Dragonfly.LogData("createReq - send " + t), Dragonfly.LogResourceOrder(t), r.appendChild(n))
                },

    Where when i check with console.log the object n was only <script type="text/javascript"></script> without any src at the case of failing. 

    Monday, June 5, 2017 10:28 AM
  • Can you try loading the map script using a standard script tag and see if that makes a difference. It looks like you are using  the jQuery getScript tag. The Bing Maps control loads a small javascript file which then loads all the resources it needs (javascript and css files). Using the getScript function may be causes a security issue as this would dynamically load the initial script which wouldn't let that script from loading the additional resources.

    [Blog] [twitter] [LinkedIn]

    Monday, June 5, 2017 4:08 PM