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

Syntax

MGCollection getMapLayersEx()

Description

Gets an MGCollection object containing all the map layers defined in the map.

This method replaces the getMapLayers method in earlier versions of the Autodesk MapGuide Viewer API and supports the Autodesk MapGuide Viewer Plug-In, Java Edition, and ActiveX Control with the same syntax. The older method will still work in Release 6, but you should use getMapLayersEx in all future development.

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.

Returns

MGCollection - An MGCollection object.

Error Codes

none

Example

The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It displays a dialog box listing all the layers in the map. The getMapLayersEx() method is used to obtain the map layer collection and to assign it to a variable named layers. Note the use of the size() and item() methods, which operate on the collection variable:

function listLayers()
{    
    var map = getMap();
    var msg = "";  
    
    // Assign collection to layers variable
    var layers = map.getMapLayersEx();    
    // Use size() to step through collection      
    for (var i = 0; i < layers.size(); i++)  
    {
        // Get each item in collection...
        var layer = layers.item(i); 
        // ...then get item name and add it to msg  
        msg = msg + layer.getName() + "\n";
    }   
    // Display the layer names
    alert(msg);
}  

See Also

MapLayers, getMapLayer, getMapLayers