Maps.Location undefined While Loading script dynamically RRS feed

  • Question

  • Hi, I'm trying to create script tag and load the script dynamically. Using this URL:

    I am creating onload event of script tag and trying to load the map after that. But I 'm getting error while accessing Microsoft.Maps.Location and other functions after script has been loaded.

     Please assist.


    Wednesday, April 13, 2016 5:29 AM


  • The Bing Maps control loads a bunch of scripts dynamically on its own. What is likely happening is that you are trying to access it before it has loaded the required scripts. To handle this you can use the callback URL parameter for the map script. For example, if you have some function that dynamically loads scripts called loadScriptDynamically, the following code would work:

    function mapScriptLoaded(){
    	//Script is loaded, start using Microsoft.Maps namespace.

    Alternatively, if you want to include a script reference in your page, you can also use async defer like this:

    <script type='text/javascript' src='' async defer></script>

    This is documented here:

    [Blog] [twitter] [LinkedIn]

    Wednesday, April 13, 2016 2:56 PM