| MGMap.addMapLayers |
|
ActiveX Control: boolean addMapLayers(MGCollection URLs)
Plug-In/Java Edition: boolean addMapLayers(MGCollection URLs, MGAddMapLayerObserver observer)
Downloads and adds the specified Map Layer Files to the map.
It then fires the onAddMapLayer event for each file added. Once downloads are finished, the map is updated.
For Autodesk MapGuide Viewer Plug-In, the observer parameter specifies the object that either handles the event or forwards it back to JavaScript.
This method always refreshes the map when the autoRefresh flag is set to True or when called from the onViewChanging or onMapLoaded events.
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.
URLs - An MGCollection of strings. Each string is a URL that references a map layer file.
observer - A Java object that implements MGAddMapLayerObserver (Plug-In and Java Edition only).
boolean - Returns True if successful; otherwise, returns False.
-1 (busy)
-3 (illegal argument)
The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It adds two layers, named "USStCap.mlf" and "USInterstates.mlf", to a map:
function addTwoLayers()
{
var map = getMap();
var urlCollection = map.createObject("MGCollection");
urlCollection.add("http://yourserver/maps/USStCap.mlf")
urlCollection.add("http://yourserver/maps/USInterstates.mlf")
/// check Viewer version (type)...
if (map.getViewerType() == "ActiveX Control")
// ...if IE, addMapLayers() takes URL as only argument
map.addMapLayers(urlCollection);
else
// ...if Netscape or Java, second argument also needed
map.addMapLayers(urlCollection, document.obs);
}
Like addMapLayer(), addMapLayers() requires a second argument when you use it with Autodesk MapGuide Viewer Plug-In or the Autodesk MapGuide Viewer, Java Edition.
addMapLayer, removeMapLayer, viewBuffer, onAddMapLayer