Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE error -2147024882

I am developing a web page with vb.net on the server side and some javascript on the .aspx page for google maps. The web page is a big GIS thing that maps out all of the block groups of Georgia within certain counties, so it's about 15MB of pure [latitude,longitude] points in a .js file. In chrome/firefox, the map loads up, then the script is loaded which triggers a callback to draw the polygons it defines, and the polygons are drawn onto the map. In IE, the map is loaded, and when the script is loaded the console has a SCRIPT14: error -2147024882 on line 1. Everything displays correctly besides the polygons on the map. The structure of the .js file is a declaration of only a couple of variables.

var allPolys = [
    [
      //poly1 points
      [x1,y1],
      [x2,y2],
      ...
    ],
    [
      //next poly
      [x1,y1],
      ...
    ]
]

^^ is how each polygon is defined in the .js. Is this a size issue because all of the points are within a single array?

mapping code:

            function drawPolys() {
                for (var i = 0; i < allTracts.length; i++) {
                    var tract = "new google.maps.Polygon({ strokeWeight: 0.7, path: [";
                    for (var j = 0; j < allTracts[i].length; j++)
                        tract += " new google.maps.LatLng(" + allTracts[i][j][0] + "," + allTracts[i][j][1] + "),";
                    tract = tract.substring(0, tract.length - 1) + "], map: map });";
                    eval(tract);
                }

                //this is all for other 'multipolygons' that are in some maps
                var colors = ['red', 'blue', 'green', 'orange', 'yellow', 'white'];

                for (var i = 0; i < multiPolys.length; i++) {
                    for (var j = 0; j < multiPolys[i].length; j++) {
                        var subTract = "new google.maps.Polygon({ strokeWeight: 1.5, strokeColor: '" + colors[i % colors.length] + "', fillColor: '" + colors[i % colors.length] + "', path: [";
                        for (var k = 0; k < multiPolys[i][j].length; k++)
                            subTract += " new google.maps.LatLng(" + multiPolys[i][j][k][0] + "," + multiPolys[i][j][k][1] + "),";
                        subTract = subTract.substring(0, subTract.length - 1) + "], map: map });";
                        eval(subTract);
                    }
                }
            }

In Chrome the page loads beautifully.

edit : the new mapping function without eval()'s

            function drawPolys() {
                for (var i = 0; i < allTracts.length; i++) {
                    var path = [];
                    for (var j = 0; j < allTracts[i].length; j++)
                        path.push(new google.maps.LatLng(allTracts[i][j][0],allTracts[i][j][1]));
                    new google.maps.Polygon({ strokeWeight: 0.7, path: path, map: map });
                }

                var colors = ['red', 'blue', 'green', 'orange', 'yellow', 'white'];

                for (var i = 0; i < multiPolys.length; i++) {
                    var path = [];
                    for (var j = 0; j < multiPolys[i].length; j++) {
                        path[j] = [];
                        for (var k = 0; k < multiPolys[i][j].length; k++)
                            path[j].push(new google.maps.LatLng(multiPolys[i][j][k][0],multiPolys[i][j][k][1]));
                    }
                    new google.maps.Polygon({ strokeWeight: 1.5, strokeColor: colors[i % colors.length], fillColor: colors[i % colors.length], paths: path, map: map });
                }
            }
like image 564
Jay Elrod Avatar asked Aug 06 '12 17:08

Jay Elrod


2 Answers

I believe I’ve found the exact cause of this error.

EDIT: I believe this bug was fixed as of IE 10

My testing suggests that IE will refuse to execute a Javascript file with more than 216-3 numbers in it. So, if a .js file has 65533 numbers, IE will execute it. But if it contains 65534 or more numbers, you will get error −2147024882.

I put up a test case demonstrating this problem here:

http://ie-error-2147024882.s3.amazonaws.com/ie_error_-2147024882.html

The site I’m working on loads large sets of JSON data from Javascript files hosted on S3. At first I thought this was due to some Javascript source file size limitation in IE. But a bit of testing revealed that IE can handle .js files that were much, much bigger than the ones that were setting off this mysterious −2147024882 error.

The workaround, in my case, was to encode ints and floats as strings when generating the .js files and use parseInt and parseFloat to interpret them.

like image 185
can_i_help Avatar answered Nov 01 '22 17:11

can_i_help


As far as my Googling goes this seems to be an "out of memory"-issue:

"Error -2147024882 There is not enough memory available to perform the operation. - MAPI_E_NOT_ENOUGH_MEMORY (Microsoft Exchange Server Information Store)

Check the lengths in you're for loops (multiPolys and allTracts)

And also check the length of you're string tract and subTract, they might be too long

like image 42
Sindre Avatar answered Nov 01 '22 18:11

Sindre