I am working with AutoCad Mapguide, and having a huge javascript problem. The problem stems from the fact that the actual Mapguide activeX cannot be manipulated when it is in a "busy" state, and therefore I must wait for it to leave that state before I can further interact with it. (the page uses frames)
The basic structure is as follows:
In top layer, which is not ever refreshed:
In a side layer (named info, parent = top), which does not refresh until the very end:
The way I understand this to work is that the top function will execute, and if the map is busy it will set a timeout which allows the map to continue working and try again in 1 second.
In practice, however, the top function calls the second info function no matter what, and if the map was busy, the timeout is set but evaluates later.
Anyone have any ideas on how to wait for a flag to change (while allowing continued operation) before calling the next step in a procedure?
Thank you
The basic structure is as follows:
In top layer, which is not ever refreshed:
Code:
function whenMapReady(str)
{
var busy = mapFrame.getMap().isBusy();
if (busy){setTimeout("whenMapReady("+str+")",1000);}
if (!busy) {eval (str);}
}
In a side layer (named info, parent = top), which does not refresh until the very end:
Code:
function send() { //Turns on layer, zooms wide, clears selection
myMap = parent.mapFrame.getMap();
myMap.zoomWidth(<%=centerY%>,<%=centerX%>,SetWidth(<%=height%>,<%=width%>),"FT");
var layers = myMap.getMapLayerGroup("LotInfo")
layers.setVisibility(true);
var mapSel = myMap.getSelection();
mapSel.clear(); //this sends map into busy state
parent.whenMapReady("self.info.zoomToSelection()");
}
function zoomToSelection(){//Zooms to the selection found
myMap.zoomSelected();
}
The way I understand this to work is that the top function will execute, and if the map is busy it will set a timeout which allows the map to continue working and try again in 1 second.
In practice, however, the top function calls the second info function no matter what, and if the map was busy, the timeout is set but evaluates later.
Anyone have any ideas on how to wait for a flag to change (while allowing continued operation) before calling the next step in a procedure?
Thank you