| MGMap.removeMapLayer |
|
boolean removeMapLayer(String layerName)
Removes the specified map layer from the map.
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.
layerName - The name of the map layer to remove from the map.
boolean - Returns True if layer successfully removed; False if layer does not exist.
-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 takes a layer name as its argument. If the layer exists, it is removed from the map. Otherwise, an alert displays:
function removeLayer(name)
{
if ( getMap().removeMapLayer(name) == true )
alert(name + " layer removed.");
else
alert(name + " layer not found!");
}
You might use the following HTML to call the function on a layer called "World Countries":
<FORM>
<INPUT TYPE="button" VALUE="Toggle" ONCLICK="removeLayer('World Countries');">
</FORM>