I'm working on a project that repeatedly adds and removes layers from the map.
I've been seeing intermittent errors in Layers.Grid.moveTo() - this.grid.length not defined, because this.grid is null.
I think that what is happening is that moveTo() is sometimes being called on a layer after the layer has been destroyed. Layer.destroy() calls Grid.destroy(), and Grid.destroy() sets this.grid to null.
My code, when I'm removing a layer, is:
openLayersMap.removeLayer(layer);
layer.destroy();
layer = null;
My hack to make the symptom go away is to change Grid.moveTo().
from:
moveTo:function(bounds, zoomChanged, dragging) {
if (bounds == null) {
bounds = this.map.getExtent();
}
if (bounds != null) {
...
to:
moveTo:function(bounds, zoomChanged, dragging) {
if (bounds == null) {
bounds = this.map.getExtent();
}
if (bounds != null && this.grid != null) {
...
But I don't think this addresses the cause.
I haven't been able to make this happen on demand. I think there may be some sort of timing sensitive situation that allows it.
Revision 1418.