MGMap.removeMapLayer   Go to object model Go to parent topic Go to previous topic Go to next topic

Syntax

boolean removeMapLayer(String layerName)

Description

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.

Parameters

layerName - The name of the map layer to remove from the map.

Returns

boolean - Returns True if layer successfully removed; False if layer does not exist.

Error Codes

-1 (busy)

-3 (illegal argument)

Example

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>

See Also

addMapLayer, viewBuffer