| MGMap.getMapLayer |
|
MGMapLayer getMapLayer(String layername)
Gets the specified map layer.
layername - Name of the map layer to return.
MGMapLayer - The specified map layer, or null if no layer exists with the given name.
-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, its visibility is toggled. Otherwise, an alert displays:
function layerToggle(name)
{
var map = getMap();
var layer = map.getMapLayer(name);
if (layer == null)
alert("layer not found.");
else
layer.setVisibility(!layer.getVisibility());
map.refresh();
}
You might use the following HTML to call the function on a layer called "World Countries":
<FORM>
<INPUT TYPE="button" VALUE="Toggle" ONCLICK="layerToggle('World Countries');">
</FORM>
MapLayers, getMapLayersEx, getMapLayers