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_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users