| MGCollection.add |
|
void add(object obj)
Adds the specified object to the collection.
obj - The object to be added.
none
This example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It uses the add method to populate an MGCollection called mapObjects. Note the use of getMapObject to obtain the objects by key before adding them to the collection:
function selectSomeStates()
{
// Get map object; then get "States" layer
map = getMap();
var mapLayer = map.getMapLayer("States");
// Create an MGCollection object called mapFeatures
var mapFeatures = map.createObject("MGCollection");
// Get features by key, then add to mapFeatures collection
mapFeatures.add(mapLayer.getMapObject("AZ")); // key is "AZ"
mapFeatures.add(mapLayer.getMapObject("CA")); // key is "CA"
mapFeatures.add(mapLayer.getMapObject("NV")); // key is "NV"
// Select and display contents of mapFeatures
map.getSelection().addObjectsEx(mapFeatures, true);
}