문제

Demo: http://picturethiswebcenter.com/ods_map/

When I access this map from ie8, it throws an "Object doesn't support this property or method" error on this line of csv2geojson.js,

var parsed = (typeof x == 'string') ? dsv(options.delimiter).parse(x) : x;

I have been doing a bit of googling but cannot figure what ie8 is missing here, any reason why this line might throw an error?

도움이 되었습니까?

해결책

The DSV library that csv2geojson.js uses some "build-in" functions that aren't supported in IE8, namely map function. Other parts of the code uses forEach. I pulled up the following snippet from the DSV code:

function dsv(delimiter) {
  var dsv = {},
      reFormat = new RegExp("[\"" + delimiter + "\n]"),
      delimiterCode = delimiter.charCodeAt(0);

  dsv.parse = function(text, f) {
    var o;
    return dsv.parseRows(text, function(row, i) {
      if (o) return o(row, i - 1);
      var a = new Function("d", "return {" + row.map(function(name, i) {
        return JSON.stringify(name) + ": d[" + i + "]";
      }).join(",") + "}");
      o = f ? function(row, i) { return f(a(row), i); } : a;
    });
  };
  ...

The .map and .forEach Array functions are implemented only in JavaScript 1.6 (ECMAScript 5) and higher. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map#Browser_compatibility .

Long story short, if you want it to work in IE, your code will only work in IE9 or higher. Other options is to rewrite DSV library to be compatible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top