none
v8 Uncaught TypeError: Microsoft.Maps.Location is not a constructor RRS feed

  • Question

  • Uncaught TypeError: Microsoft.Maps.Location is not a constructor issued (in Chrome -- Edge issues SCRIPT5007: Unable to get property 'prototype' of undefined or null reference error) for the following super-simple-just-like-the-example-code:

    function BingMap() {

    // Load the map var map = new Microsoft.Maps.Map(document.getElementById("myMap"), { credentials: "my-bing-map-key-here", center: new Microsoft.Maps.Location(30.233718431019124, -97.78610944747925), zoom: 15 });    var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), { color: 'rgb(69, 67, 25)' }); map.entities.push(pushpin);

    }

    Console message state location is not a constructor even when I place it into its own line

    var loc = new Microsoft.Maps.Location(30.233718431019124, -97.78610944747925);

    This is practically identical to the example in the interactive testbed -- in fact -- it WORKS via the interactive testbed.  http://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#loadMapWithOptions+JS  but does not work via my localhost webserver. Suggestions?



    • Edited by carl.camera Thursday, March 9, 2017 1:20 AM
    Thursday, March 9, 2017 12:54 AM

Answers

  • ERROR SOLVED

    Even though I was loading the script synchronously ie

    < script src="http://www.bing.com/api/maps/mapcontrol" > < / script>

    objects it seem were not loaded.  The fix was to make the bing map call asynchronous with a callback

    < script src="http://www.bing.com/api/maps/mapcontrol?callback=BingMap" async defer > < / script>

    ..and the map loads fine now.  I took out the existing "on load" call to the BingMap function

    • Marked as answer by carl.camera Thursday, March 9, 2017 1:19 AM
    Thursday, March 9, 2017 1:19 AM

All replies

  • ERROR SOLVED

    Even though I was loading the script synchronously ie

    < script src="http://www.bing.com/api/maps/mapcontrol" > < / script>

    objects it seem were not loaded.  The fix was to make the bing map call asynchronous with a callback

    < script src="http://www.bing.com/api/maps/mapcontrol?callback=BingMap" async defer > < / script>

    ..and the map loads fine now.  I took out the existing "on load" call to the BingMap function

    • Marked as answer by carl.camera Thursday, March 9, 2017 1:19 AM
    Thursday, March 9, 2017 1:19 AM
  • I'm still having the same issue, are you? I feel this new binv map v8 script is missing a good Q/A
    Tuesday, March 14, 2017 5:18 AM
  • The v8 control has a lot more q/a than v7 ever did and less bugs than it did by a long shot. Make sure to load the map asynchronously. The likely issue is that the map script isn't loaded yet when you are trying to access its classes.

    [Blog] [twitter] [LinkedIn]

    Tuesday, March 14, 2017 5:29 AM
  • Well, that has not been my case. I get this issue and also I get this error:

    `window[Microsoft.Maps.CallbackOnLoad] is not a function`

    This is an error on the script itself.

    v7 never gave me any issues at all.



    • Edited by futoricky Wednesday, March 15, 2017 5:43 PM
    Wednesday, March 15, 2017 5:42 PM
  • I am having the same problem: when I make it async, it just goes from having one error to having two, the second one being that CallbackOnLoad is not a function. I am using Chrome.
    Monday, May 15, 2017 2:45 PM
  • I'm also facing the same issue when I make it async, it just goes from having one error to having two, the second one being that CallbackOnLoad is not a function. I am using Chrome.
    Monday, June 12, 2017 4:03 AM
  • Is there an update on this? I too have same issue with Chrome Safari, etc., when trying to load async.
    Wednesday, June 28, 2017 7:20 PM