| MGMap.isBusy |
|
boolean isBusy()
Returns True if Autodesk MapGuide Viewer is busy loading or drawing the map.
Before calling other API methods, you should use the isBusy method in an if statement to test whether the Autodesk MapGuide Viewer is busy.
Do not attempt to use isBusy in a while loop to wait until Autodesk MapGuide Viewer becomes available. This may cause the Web browser and Autodesk MapGuide Viewer to freeze up.
boolean - Returns True if busy; otherwise, returns False.
none
The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It displays a dialog box showing whether the map is busy or not:
function getBusy()
{
map = getMap();
if (map.isBusy())
alert("busy!");
else
alert("not busy!");
}
Here's a more meaningful use of isBusy(). The following example counts the features on each map layer and adds that count to the legend:
// This global variable tells us if showFeatureCount() has already
// added the legend info; if the function hasn't run successfully,
// the value will remain false
legendSet = false;
// Function starts here
function showFeatureCount() {
// Exit function if legend info has already been added
if (legendSet)
return;
var map = getMap();
// If map is NOT busy, add legend info; otherwise, exit
if (!map.isBusy())
{
var layers = map.getMapLayersEx();
var cnt = layers.size();
var i;
var msg = "";
for (i = 0; i < cnt; i++)
{
var layer = layers.item(i);
var featureCount = layer.getMapObjectsEx().size();
var label = layer.getLegendLabel();
label = label + " " + featureCount + " features";
layer.setLegendLabel(label);
}
// Change variable to true, showing that
// legend info has been added
legendSet = true;
}
}
If the map is busy, the function will be unable to get the feature count and add it to the legend. By using isBusy(), you can make sure the legendSet variable updates only if the legend has updated successfully.