none
Ajax v7 IE 7 throws undefined is null when adding a polygon RRS feed

  • Question

  • The following code throws a 'undefined' is null or not an object error in IE 7 (works perfectly in all other browsers).

     

    I've narrowed it down to this line, the actual pushing of the polygon to the map:

    map.entities.push(new MM.Polygon(parcelArr,{
    				fillColor: new MM.Color(0,0,0,0)
    }));

    I'm really at a lose here.  Anyone else had similar issues?

     

            var MM = Microsoft.Maps;
    		var parcelLayer = new MM.EntityCollection();
    		var zoomChecker = null;
    		var theParcel = null;	
    		function loadmap()
    		{
    		  var centerpoint = new MM.Location(parseFloat(36.822657),parseFloat(-76.213682));
    		  var mapOptions = {credentials: "myKey",
         	  mapTypeId: MM.MapTypeId.birdseye,
    	      showDashboard: false,
    	      enableClickableLogo: false,
    	      enableSearchLogo: false,
    	      showLogo: false,
    	      center: centerpoint,
    	      zoom: 19,
    	      showCopyright: false,
    	      showScalebar: false,
    	     disableUserInput: true	
             }
    				map = new MM.Map(document.getElementById("cmMap"),mapOptions);
    				var pushpinOptions = {				
    					text: "",
    					icon: "icon.png",				
    					width: 30,
    					height: 47
    				}
    				var pin = new MM.Pushpin(centerpoint,pushpinOptions);
    				map.entities.push(pin);
    				map.entities.push(parcelLayer);
    				
    					var loc = null;
    					
    					var parcelArr = []; 
    					parcelArr = [new MM.Location(parseFloat(36.822854),parseFloat(-76.213127)),new MM.Location(parseFloat(36.823555),parseFloat(-76.212814)),new MM.Location(parseFloat(36.823582),parseFloat(-76.212903)),new MM.Location(parseFloat(36.823159),parseFloat(-76.213091)),new MM.Location(parseFloat(36.823144),parseFloat(-76.213143)),new MM.Location(parseFloat(36.823138),parseFloat(-76.213591)),new MM.Location(parseFloat(36.823138),parseFloat(-76.213599)),new MM.Location(parseFloat(36.823136),parseFloat(-76.213612)),new MM.Location(parseFloat(36.823134),parseFloat(-76.213625)),new MM.Location(parseFloat(36.823088),parseFloat(-76.213611)),new MM.Location(parseFloat(36.822989),parseFloat(-76.21378)),new MM.Location(parseFloat(36.822978),parseFloat(-76.21377)),new MM.Location(parseFloat(36.822904),parseFloat(-76.213767)),new MM.Location(parseFloat(36.822745),parseFloat(-76.213683)),new MM.Location(parseFloat(36.822726),parseFloat(-76.21374)),new MM.Location(parseFloat(36.822344),parseFloat(-76.21354)),new MM.Location(parseFloat(36.822474),parseFloat(-76.213244)),new MM.Location(parseFloat(36.822553),parseFloat(-76.213298)),new MM.Location(parseFloat(36.822792),parseFloat(-76.213386)),new MM.Location(parseFloat(36.822854),parseFloat(-76.213127))];
    					map.entities.push(new MM.Polygon(parcelArr,{
    						fillColor: new MM.Color(0,0,0,0)
    					}));																		
    			}
    
    

     

    • Moved by Ricky_Brundritt Saturday, March 10, 2012 11:16 AM (From:Bing Maps: Map Control and Web services Development)
    Thursday, March 24, 2011 1:07 PM

Answers

  • Yes, actually.  The original code had the Polygon added to the parcelLayer.

     

    Oddly enough, I updated from jQuery 1.5 to jQuery 1.5.1 today and that seemed to have fixed the issue.

    That's great news. jQuery had an issue with VML from version 1.4.2 through 1.5. Didn't know that 1.5.1 fixed it... :)
    Thursday, March 24, 2011 7:22 PM

All replies

  • Have you tried adding the polygon to the parcelLayer collection rather than to the base map? (i'm guessing that's what you created the layer for....). i.e. instead of:

    map.entities.push(new MM.Polygon(parcelArr,{

    use

    parcelLayer.push(new MM.Polygon(parcelArr, {

    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Thursday, March 24, 2011 2:49 PM
    Moderator
  • Yes, actually.  The original code had the Polygon added to the parcelLayer.

     

    Oddly enough, I updated from jQuery 1.5 to jQuery 1.5.1 today and that seemed to have fixed the issue.

    Thursday, March 24, 2011 4:40 PM
  • Yes, actually.  The original code had the Polygon added to the parcelLayer.

     

    Oddly enough, I updated from jQuery 1.5 to jQuery 1.5.1 today and that seemed to have fixed the issue.

    That's great news. jQuery had an issue with VML from version 1.4.2 through 1.5. Didn't know that 1.5.1 fixed it... :)
    Thursday, March 24, 2011 7:22 PM
  • Updating jQuery to 1.5.2 did not fix the issue. I still get the error in "veapicore.js" undefined error. The error happens randomly. There is no pattern to when it happens.
    Tuesday, April 12, 2011 9:56 PM
  • Yes, actually.  The original code had the Polygon added to the parcelLayer.

     

    Oddly enough, I updated from jQuery 1.5 to jQuery 1.5.1 today and that seemed to have fixed the issue.


    Updating jQuery to 1.5.2 did not fix the issue. I still get the error in "veapicore.js" undefined error. The error happens randomly. There is no pattern to when it happens.
    Tuesday, April 12, 2011 9:57 PM
  • @maneeshrampally - this thread is marked as answered, which means that you're unlikely to get an answer to your question. Are you using exactly the same code as the OP in this thread? If not, please start a new thread, including a full description of the error and the code used to create your map, or a link to your map.
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Wednesday, April 13, 2011 8:06 AM
    Moderator
  • I should note that this error has returned and that upgrading is not a solution.
    Thursday, April 14, 2011 3:49 PM
  • Well,

    Apparently there is good news and bad news.

     

    The good news is that the issue has been solved 3 days ago.

    The bad news is that it will only be released on jQuery 1.6

    Anyway, I got this info at the jQuery bug tracker for this particular issue (http://bugs.jquery.com/ticket/7071), and there is a "hack" listed there that worked for me. I don't like it particularly, but while waiting for the official fix from jQuery it will have to do...

    ---

    Modify the jquery file and replace all the calls from "elem.type" to "jQuery.elemGetType(elem)".

    Afterwards add the following code inside the jquery file:

    Query.extend({
      elemGetType: function(elem) {
        if (elem && jQuery.browser.msie && elem.scopeName &&
            elem.scopeName != 'HTML' &&
            document.namespaces.item(elem.scopeName).urn.toLowerCase() ==
            'urn:schemas-microsoft-com:vml') {
          return 'vml';
        }
        return elem.type
      }
    }

    ---

    Saturday, April 16, 2011 2:32 AM
  • I have replaced elem.type in jquery1.5.2.js

    and also added the elemGetType function......

    But it still throws the same error. The error is happening when I trying to add a polygon to bing maps.

     

    Any help would be highly appreciated

     

    Sunday, April 24, 2011 4:24 PM
  • For those poor unfortunate souls that land here via a Google search looking for answers to this situation, the answer is here:

    http://bugs.jquery.com/ticket/9046

    Basically, if you're hooking $(document).ready(...) to initialize your map, that's too soon.  Internet Explorer uses VML, rather than SVG, to render polygons and polylines in the Bing Maps AJAX control.  The VML subsystem in IE is not (necessarily) ready-to-go when document.ready is fired, so, instead, use $(window).load(...).  I lost much blood, sweat, and tears trying to chase this down.

    Now, IMO, since the choice between VML versus SVG happens under the hood in the Bing Maps API based on browser detection, I would venture a guess that this could be fixed to transparently defer anything that requires the VML subsystem to be loaded, rather than silently fail only to explode later.  Even throwing an error saying something to the effect of "Browser not ready yet, initialize later in the page lifecycle" would be preferable to the current behavior.  Hope this helps someone.

    • Proposed as answer by samymassoud Monday, September 12, 2011 10:21 AM
    Thursday, June 16, 2011 4:44 PM
  • FMM_SST's answer solved it for me (i.e. - simply moving the init map code into the $(window).load(...) function, instead of using the familiar $(document).ready(...) function to do it. 

    What a headache this was. Thanks so much for the fix !!!

    Tuesday, October 4, 2011 1:26 AM