MGCollection.size   Go to object model Go to parent topic Go to previous topic Go to next topic

Syntax

int size()

Description

Gets the number of map features in the collection that have been displayed in the view since the last reload or rebuild of the map layer.

Returns

int - The size of the collection.

Error Codes

none

Example

This 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. First, MGMap.getMapLayersEx is used to obtain the map layer collection and to assign it to a variable named layers. Then, size and item are used in a for loop to operate on each item in the collection:

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);
}