Receive "Uncaught TypeError" from OpenLayers.Event.observe method when zoom in while processing WMS request from previous zoom operation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Receive "Uncaught TypeError" from OpenLayers.Event.observe method when zoom in while processing WMS request from previous zoom operation

sbrooke

Hi list,

I am using OpenLayers 2.13.1.

 

I am experiencing a problem when zoom in/out while OpenLayers is in process of loading images from several WMS requests that resulted from a previous zoom operation.

 

Uncaught TypeError: Cannot read property '_eventCacheID' of null                         OpenLayers.debug.js:5178                                         

OpenLayers.Event.observe                                                                                                        OpenLayers.debug.js:5178                                         

tile.onLoadEnd                                                                                                                                 OpenLayers.debug.js:31046                       

OpenLayers.Events.OpenLayers.Class.triggerEvent                                                                        OpenLayers.debug.js:5812                                         

OpenLayers.Tile.OpenLayers.Class.unload                                                                          OpenLayers.debug.js:29266                       

OpenLayers.Tile.Image.OpenLayers.Class.draw                                                                OpenLayers.debug.js:29584                       

OpenLayers.Layer.Grid.OpenLayers.Class.initGriddedTiles                                          OpenLayers.debug.js:30957                       

OpenLayers.Layer.Grid.OpenLayers.Class.moveTo                                                         OpenLayers.debug.js:30428                       

OpenLayers.Map.OpenLayers.Class.moveTo                                                                     OpenLayers.debug.js:9299                                         

map.zoomTween.start.callbacks.done                                                                                  OpenLayers.debug.js:9682                                         

OpenLayers.Tween.OpenLayers.Class.stop                                                                        OpenLayers.debug.js:6697                                         

OpenLayers.Tween.OpenLayers.Class.play                                                                         OpenLayers.debug.js:6730                                         

(anonymous function)                                                                                                                  OpenLayers.debug.js:615                                           

loops.(anonymous function)                                                                                                     OpenLayers.debug.js:6528

 

 

I am having an extremely difficult time trying to determine what my app is doing to make OpenLayers react this way.  The effect of the error is that zoom in/out capability breaks on the map until I reload the page.

Can someone enlighten me as to what may be going on here?

 

 

More background on the problem:

============================

One way I have been able to avoid the problem, although it is not an acceptable solution, is to add the following code near the top of the “OpenLayers.Event.observe” method:

 

        if (element == null){

                //console.log("element: " + element + ", name: " + name + ", observer: " + observer + ", " + "useCapture: " + useCapture);

                return;

        }

 

Like this:

 

    /**

     * Method: observe

     *

     * Parameters:

     * elementParam - {DOMElement || String}

     * name - {String}

     * observer - {function}

     * useCapture - {Boolean}

     */

    observe: function(elementParam, name, observer, useCapture) {

        var element = OpenLayers.Util.getElement(elementParam);

        useCapture = useCapture || false;

 

       //Begin added lines

        if (element == null){

                //console.log("element: " + element + ", name: " + name + ", observer: " + observer + ", " + "useCapture: " + useCapture);

                return;

        }

       //End added lines

 

        if (name == 'keypress' &&

           (navigator.appVersion.match(/Konqueror|Safari|KHTML/)

           || element.attachEvent)) {

            name = 'keydown';

        }

 

        //if observers cache has not yet been created, create it

        if (!this.observers) {

            this.observers = {};

        }

 

        //if not already assigned, make a new unique cache ID

        if (!element._eventCacheID) {                         ç============= This is the line the error occurs because “element” is null

            var idPrefix = "eventCacheID_";

            if (element.id) {

                idPrefix = element.id + "_" + idPrefix;

            }

            element._eventCacheID = OpenLayers.Util.createUniqueID(idPrefix);

        }

 

 


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Receive "Uncaught TypeError" from OpenLayers.Event.observe method when zoom in while processing WMS request from previous zoom operation

sbrooke

More info on this.  Here are the values of the arguments to the OpenLayers.Event.observe method when the problem occurs:

 

element: null, name: oTransitionEnd, observer: function () {

            // Push on any additional arguments from the actual function call.

            // These will come after those sent to the bind call.

            var newArgs = args.concat(

                Array.prototype.slice.apply(arguments, [0])

            );

            return func.apply(object, newArgs);

        }, useCapture: false

 

--Steve

 

From: Stephen Brooke
Sent: Tuesday, October 21, 2014 10:00 PM
To: '[hidden email]'
Subject: Receive "Uncaught TypeError" from OpenLayers.Event.observe method when zoom in while processing WMS request from previous zoom operation

 

Hi list,

I am using OpenLayers 2.13.1.

 

I am experiencing a problem when zoom in/out while OpenLayers is in process of loading images from several WMS requests that resulted from a previous zoom operation.

 

Uncaught TypeError: Cannot read property '_eventCacheID' of null                         OpenLayers.debug.js:5178                                         

OpenLayers.Event.observe                                                                                                        OpenLayers.debug.js:5178                                         

tile.onLoadEnd                                                                                                                                 OpenLayers.debug.js:31046                       

OpenLayers.Events.OpenLayers.Class.triggerEvent                                                                        OpenLayers.debug.js:5812                                         

OpenLayers.Tile.OpenLayers.Class.unload                                                                          OpenLayers.debug.js:29266                       

OpenLayers.Tile.Image.OpenLayers.Class.draw                                                                OpenLayers.debug.js:29584                       

OpenLayers.Layer.Grid.OpenLayers.Class.initGriddedTiles                                          OpenLayers.debug.js:30957                       

OpenLayers.Layer.Grid.OpenLayers.Class.moveTo                                                         OpenLayers.debug.js:30428                       

OpenLayers.Map.OpenLayers.Class.moveTo                                                                     OpenLayers.debug.js:9299                                         

map.zoomTween.start.callbacks.done                                                                                  OpenLayers.debug.js:9682                                         

OpenLayers.Tween.OpenLayers.Class.stop                                                                        OpenLayers.debug.js:6697                                         

OpenLayers.Tween.OpenLayers.Class.play                                                                         OpenLayers.debug.js:6730                                         

(anonymous function)                                                                                                                  OpenLayers.debug.js:615                                           

loops.(anonymous function)                                                                                                     OpenLayers.debug.js:6528

 

 

I am having an extremely difficult time trying to determine what my app is doing to make OpenLayers react this way.  The effect of the error is that zoom in/out capability breaks on the map until I reload the page.

Can someone enlighten me as to what may be going on here?

 

 

More background on the problem:

============================

One way I have been able to avoid the problem, although it is not an acceptable solution, is to add the following code near the top of the “OpenLayers.Event.observe” method:

 

        if (element == null){

                //console.log("element: " + element + ", name: " + name + ", observer: " + observer + ", " + "useCapture: " + useCapture);

                return;

        }

 

Like this:

 

    /**

     * Method: observe

     *

     * Parameters:

     * elementParam - {DOMElement || String}

     * name - {String}

     * observer - {function}

     * useCapture - {Boolean}

     */

    observe: function(elementParam, name, observer, useCapture) {

        var element = OpenLayers.Util.getElement(elementParam);

        useCapture = useCapture || false;

 

       //Begin added lines

        if (element == null){

                //console.log("element: " + element + ", name: " + name + ", observer: " + observer + ", " + "useCapture: " + useCapture);

                return;

        }

       //End added lines

 

        if (name == 'keypress' &&

           (navigator.appVersion.match(/Konqueror|Safari|KHTML/)

           || element.attachEvent)) {

            name = 'keydown';

        }

 

        //if observers cache has not yet been created, create it

        if (!this.observers) {

            this.observers = {};

        }

 

        //if not already assigned, make a new unique cache ID

        if (!element._eventCacheID) {                         ç============= This is the line the error occurs because “element” is null

            var idPrefix = "eventCacheID_";

            if (element.id) {

                idPrefix = element.id + "_" + idPrefix;

            }

            element._eventCacheID = OpenLayers.Util.createUniqueID(idPrefix);

        }

 

 


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users