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

Syntax

void selectPolygonMode()

Description

Enters the select polygon mode.

In this mode, Autodesk MapGuide allows the user to digitize a polygon and select all map features that fall within the polygon.

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 polygon selection mode.

Note that the user can make a polygon selection only if one or more selectable layers is visible.

function polySelect() 
{
    getMap().selectPolygonMode();
}

The next example checks for selectable map features before calling selectPolygonMode(). If one or more selectable layers is visible, the user can make a selection. Otherwise an alert displays.

// first function calls selectPolygonMode()
function polySelect()
{
    map = getMap();
    
    // call function that tests selectability 
    var test = checkSelectability();
    
    // selectable map features?
    if (test == true)
    {
        // ...if yes, user can make polygon selection
        alert("Make a polygon selection now...");
        map.selectPolygonMode();
    }
    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

selectPolygonEx