MGMap.selectMapObjectsDlg   Go to object model Go to parent topic Go to previous topic Go to next topic

Syntax

void selectMapObjectsDlg()

Description

Displays the Select Map Features dialog box, where the user can select map features by name from a specific map layer.

This method is the equivalent of the Select > Select Map Features menu command in the user interface.

Note that this method does not work during a busy state. For additional information about the busy state, refer to "Handling Busy State and Map Refresh" chapter in the Autodesk MapGuide Developer's Guide.

Error Codes

-1 (busy)

Example

The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It invokes the Select Map Features dialog box.

Note that the dialog displays only if one or more selectable layers is visible.

function showMapFeatures() 
{
    getMap().selectMapObjectsDlg();
}

The next example checks for selectable map features before calling selectMapObjectsDlg(). If one or more selectable layers is visible, the Select Map Features dialog box displays. Otherwise an alert displays.

// first function calls selectMapObjectsDlg()
function showMapFeatures()
{
    map = getMap();
    
    // call function that tests selectability 
    var test = checkSelectability();
    
    // selectable map features?
    if (test == true)
        // ....if yes, display dialog
        map.selectMapObjectsDlg();
    else
        // ...if no, display alert
        alert("Sorry, no selectable features found!");
}

// second function checks map feature selectability
function checkSelectability()
{
    var map = getMap();
    var layers = map.getMapLayersEx();
    
    // false means a selectable layer has not (yet) been found
    var selectable = false;

    // cycle through each layer in map...
    for (var i = 0; i < layers.size(); i++)
    {
        var layer = layers.item(i);
        // is the layer visible?
        if ( layer.isVisible() )
        {
            // is it selectable?
            if (layer.getSelectability())
            {
                // first time a visible/selectable layer is
                // found, set flag to true and exit loop
                selectable = true;
                break;
            } 
        }
    }
    return selectable;
}

See Also

MGSelection