none
Getting Uncaught TypeError: Cannot read property 'prototype' of null after moving to v8 RRS feed

  • Question

  • When I instance a new Map I am getting the referenced error.

    The offending code is:

    m = new Microsoft.Maps.Map(document.getElementById(elementID), { credentials: this.mapKey });

    I have verified that the element exists and that my key is still correct (unless I need a new key for v8? The porting docs said nothing of the sort unless I missed it).

    This line seems pretty innocuous so I am at a loss.

    Here is the entire stacktrace of the error in case it helps:

    mapcontrol:11 Uncaught TypeError: Cannot read property 'prototype' of null
        at k (mapcontrol:11)
        at n.h [as create] (mapcontrol:11)
        at e (mapcontrol:11)
        at t.l [as instance] (mapcontrol:11)
        at n.h [as create] (mapcontrol:11)
        at e (mapcontrol:11)
        at t.l [as instance] (mapcontrol:11)
        at new Microsoft.Maps.Map (mapcontrol:13)
        at Object.addMap (Map_Library.js:22)
        at Object.initialize (MainMap.js:25)

    I am also getting this error next:

    GET http://localhost:53035/e486222e867b470aabbdfc1232ff50eb/browserLink net::ERR_CONNECTION_REFUSED

    Wednesday, August 23, 2017 11:57 PM

Answers

All replies

  • I suspect the issue is that the map script hasn't finished loading before your call to create a map is made. V8 is asynchronous in nature and loads its resources in a non-blocking way so the rest of your page can load fast. When do you load the map? When the onload function of the page's body fires? Using document.ready? 

    [Blog] [twitter] [LinkedIn]

    Thursday, August 24, 2017 12:21 AM
  • I use Ext JS for my UI and there is function called Ext.onReady which is similar to document.ready, it fires after Ext is all loaded and ready to fire. Within that callback I create the page layout and then finally initialize the map. it is not advisable to mix Ext.onReady and document.ready.

    Looking at the docs, I am not seeing a way to give Maps a chance to finish loading before I start using it or any event that can fire when it is loaded.

    Do I need to start using loadModule?

    For now, I just need to get off of v7 even if my code is not pretty. Then I will take full advantage of v8, with all of the re-architecting/refactoring that will entail, when I have some extra bandwidth. Seeing some of the new v8 stuff, I am looking forward to it.

    Thanks, Brad

    Friday, August 25, 2017 4:52 AM
  • Ok, Ext.onReady is likely firing before the map script has finished loading. There are two options:


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Friday, August 25, 2017 7:05 PM
    • Marked as answer by Brad Mathews Monday, August 28, 2017 5:31 PM
    Friday, August 25, 2017 7:05 PM
  • I used the Bing maps callback and set an isBingMaps ready flag. I did the same for Ext.onReady. then I check as each is called to see if the other is done initializing and then build my page.

    - Brad

    Monday, August 28, 2017 5:33 PM