1

I am using ol3/3.15.1/ol-debug.js, and get the error message in the console:

ol-debug.js:6326 Uncaught TypeError: Cannot read property 'call' of undefined
    at ol.source.Vector.ol.events.EventTarget.dispatchEvent (ol-debug.js:6326)
    at ol.source.Vector.ol.Observable.changed (ol-debug.js:6453)
    at ol.source.Vector.addFeatures (ol-debug.js:56141)
    at ol.source.Vector.<anonymous> (ol-debug.js:54892)
    at ol.source.Vector.<anonymous> (ol-debug.js:54831)

I have lots of js in my application, and am comfortable debugging my own code. However this error is during the rendering, after all my initiation code is processed, and I have little experience using the Chrome DevTools. It occurs once whenever each new vector layer is loaded, and seems to be about Listeners.

The Stack Trace:

ol.events.EventTarget.dispatchEvent (ol-debug.js:6326)
ol.renderer.canvas.Map.dispatchComposeEvent_ (ol-debug.js:59040)
ol.renderer.canvas.Map.renderFrame (ol-debug.js:59098)
ol.Map.renderFrame_ (ol-debug.js:68117)
(anonymous) (ol-debug.js:66987)

The code of ol-debug with the problem line (<<<<<) is:

ol.events.EventTarget.prototype.dispatchEvent = function(event) {
  var evt = typeof event === 'string' ? new ol.events.Event(event) : event;
  var type = evt.type;
  evt.target = this;
  var listeners = this.listeners_[type];
  var propagate;
  if (listeners) {
    if (!(type in this.pendingRemovals_)) {
      this.pendingRemovals_[type] = 0;
    }
    for (var i = 0, ii = listeners.length; i < ii; ++i) {
        if (listeners[i].call(this, evt) === false || evt.propagationStopped) { <<<<<<<<<<<<<<<<<
        propagate = false;
        break;
      }
    }
    var pendingRemovals = this.pendingRemovals_[type];
    delete this.pendingRemovals_[type];
    while (pendingRemovals--) {
      this.removeEventListener(type, ol.nullFunction);
    }
    return propagate;
  }
};

I have got a record of what I think is the state of the local variables at a breakpoint where the error occurs. Some of the values are:

event : ol.render.Event
type : "precompose"
listeners : Array[2]
name : "boundListener"
[[FunctionLocation]] : ol-debug.js:5910
pendingRemovals : undefined
propagate : undefined

I have made changes recently in the default vector styles area, so maybe I am causing a problem, but I cannot track it down. I cannot see that this error is having any effect on my application, as I only notice it with the console on.

Can anyone point me to where I can start looking into what I have done wrong?

closed as off-topic by whyzar, ArMoraer, nmtoken, Simbamangu, user30184 Jan 26 '17 at 21:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general IT or with no clear GIS component, are off-topic here but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software), Database Administrators (relational databases) and other SE sites" – whyzar, ArMoraer, nmtoken, Simbamangu, user30184
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Does the same happen when you use the latest version instead of v3.15.1? – ahocevar Jan 26 '17 at 18:09
  • I have now updated to OL3 v 4.0.0, and the issue disappears. Note to self: should have done this before asking the question! – Peter Cooper Feb 20 '17 at 7:02