| MGMap.createObject |
|
object createObject(String type)
Creates and returns an object of the specified type.
type - The type of object you wish to create, either MGCollection, MGExtentEx, or MGPoint. Note that this parameter is not case-sensitive.
object - The newly created MGCollection, MGExtentEx, or MGPoint object.
-3 (illegal argument)
The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It shows the use of createObject() with an MGCollection:
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);
}
To see an interesting use of this method, refer to the Selection Techniques example.