[Users] VectorLegend exception after removing layer

frank frank at spacetec.no
Mon Mar 5 17:12:10 CET 2012


Dear list

I'm using a self-made function for clearing all layers in my map and 
adding a stored set of predefined layers.
In this routine i call map.removeLayer() for all non-base layers, before 
I add the new layer set.

However, after having removed the layers I get an exception from 
GeoExt.VectorLegend:

 1. Uncaught TypeError: Cannot read property 'map' of null
     1.
        GeoExt.VectorLegend.Ext.extend.onMapZoomVectorLegend.js:261
        <http://localhost/barentswatch/GeoExt-1.1/lib/GeoExt/widgets/VectorLegend.js>
     2.
        OpenLayers.Events.OpenLayers.Class.triggerEventEvents.js:798
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Events.js>
     3.
        OpenLayers.Map.OpenLayers.Class.moveToMap.js:1890
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Map.js>
     4.
        OpenLayers.Map.OpenLayers.Class.setCenterMap.js:1662
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Map.js>
     5.
        OpenLayers.Control.Navigation.OpenLayers.Class.wheelChangeNavigation.js:279
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Control/Navigation.js>
     6.
        OpenLayers.Control.Navigation.OpenLayers.Class.wheelDownNavigation.js:303
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Control/Navigation.js>
     7.
        OpenLayers.Handler.OpenLayers.Class.callbackHandler.js:205
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Handler.js>
     8.
        OpenLayers.Handler.MouseWheel.OpenLayers.Class.wheelZoomMouseWheel.js:229
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Handler/MouseWheel.js>
     9.
        OpenLayers.Handler.MouseWheel.OpenLayers.Class.onWheelEventMouseWheel.js:191
        <http://localhost/barentswatch/OpenLayers-2.11/lib/OpenLayers/Handler/MouseWheel.js>
    10.
        (anonymous function)

To the inner level this maps down to the function
     onMapZoom: function() {
             this.setCurrentScaleDenominator(
                 this.layer.map.getScale()
             );
     },

And by inspection this.layer is undefined.

How can this be?
Removing the layer with any combination of (one or both)
     map.removeLayer(layer) and
     layer.destroy()
gives the same result.

best regards,
Frank



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20120305/efec3a43/attachment.htm 


More information about the Users mailing list