Uncaught TypeError: Cannot call method 'push' of undefined Uncaught TypeError: Cannot call method 'push' of undefined google-chrome google-chrome

Uncaught TypeError: Cannot call method 'push' of undefined


It's not really easy to tell, but basing on a comments, the object you're calling push method on is probably undefined. And this object should be an array.

Replace this line:

layer[result['layerId']].push(result);

With following code:

if("undefined" != typeof layer[result['layerId']]) {    layer[result['layerId']].push(result);}else {    layer[result['layerId']] = new Array();    layer[result['layerId']].push(result);}

Let me know if it works.