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

Syntax

MGSelection getSelection()

Description

Gets the currently selected map features.

Returns

MGSelection - The current selection.

Error Codes

none

Example

The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It zooms to the selected feature or features. If nothing is selected, an alert displays:

function zoomToSelected()
{
    var map = getMap();
    // Assign collection of selected features to variable
    var selected = map.getSelection().getMapObjectsEx(null);
    // If collection is not empty, zoom to its members...
    if (selected.size() > 0)
        map.zoomSelected();
    // ...otherwise, display alert
    else
        alert("Please make a selection first.");
}

See Also

Selection