I just wanted to add - I get the same exact error with my below code when 
switching between themes and this is called each time. Sorry not much help in 
terms of what causes it but just thought I would include another example that 
gets the same error. I just exclude my base layers and add all other layers to 
get this.



//Remove all map layers / turn off visibility of all layers
var num = (map.getNumLayers() -1);
while (num >= 0)
{
if (map.layers[num].name == 'Fake_Base' || map.layers[num].name == 'Overview 
Map Layers')
{
//do nothing
}
else if (map.layers[num].name == 'redlines')
{
map.removeLayer(map.layers[num], false);
}
else
{
map.layers[num].setVisibility(false);
map.removeLayer(map.layers[num], false);
}
num -=1;
}

//Add new layers to map, refresh map panel

map.addLayers([layer_Google_Streets,layer_Google_Hybrid, 
layer_Google_Satellite,layer_Orthos, layer_Base,layer_Parcel_Fabric, 
layer_Legal_Fabric,layer_Footprints,layer_Trails,layer_AOIs,layer_Labels,vlayer]);

mapPanel.map = map;









________________________________
From: [email protected] 
[mailto:[email protected]] On Behalf Of Mattias X 
Gustafsson
Sent: December 20, 2010 2:41 AM
To: [email protected]
Subject: [OpenLayers-Users] "this.map is null" error after removing layer from 
OpenLayers.Map

Hello,
We are getting a 'this.map is null' error, generated in openLayers.js, row 
1156, when we remove a layer with OpenLayers.Map's removeLayer-function.

I include some code from where we register the zoom event. In the case where we 
remove a layer due to current scale being lesser than the MINSCALE of the layer.
If needed I can provide more detailed/extensive code.

Two notions:
*If included, the console log 'test' gets written to Firebug console before the 
error appears. So the problem is not generated exactly at the map.removeLayer 
call, but it seem to be related.
*If we include the alert call (or step through the code with a debugger), the 
error will appear at all.

At the moment the error does not affect the functionality of our code, it works 
perfectly fine, but I still would appreciate some help in order to understand 
why the error appear.


// 'map' is an instance of OpenLayers.Map
// 'Layers' contain our instances of OpenLayers.Layer
map.events.register("zoomend", map, function() {
        for(var i in Layers){
                var currentLayerName = Layers[i].mapLayer.name;
                if (Layers[i].mapLayer.params.MINSCALE < map.getScale()) {
                        if (map.getLayersByName(currentLayerName).length == 0){
                                map.addLayer(Layers[i].mapLayer);
                        }
                }
                else if (map.getLayersByName(currentLayerName).length > 0) {
                        map.removeLayer(Layers[i].mapLayer);
                        //alert('test');
                 }
        }
        //console.log('test');
});

Best regards
Mattias Gustafsson

________________________________
[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the 
environment before printing this e-mail.]



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

Reply via email to