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

Syntax

string getName()

Description

Gets the name of the map, as set in the Preferences dialog box in Autodesk MapGuide Author, or with setName.

Returns

String - The name of the map.

Error Codes

none

Example

This simple function is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It displays an alert showing the name of the map:

function showNameInAlert()
{
    alert("The map is named " + getMap().getName() + ".");
}

You can also use getName() to display the map name dynamically as an HTML heading. The following example assumes you are working with a two-frame frameset. One frame (called mapFrame) displays a page containing the map. The other frame ('titleFrame') displays a blank HTML document that will be replaced later by the map name.

First, write a function that uses getName() to write the map name to the title frame. This function should be in the page containing the map (or in a .js file referenced by the page):

function showNameInFrame()
{
    parent.titleFrame.document.open();
    parent.titleFrame.document.write("<H1>" + getMap().getName() + "</H1>");
    parent.titleFrame.document.close();
}

Then, call the function from the onLoad event of the page containing the map:

<BODY onLoad="showNameInFrame()">

When the map page is fully loaded, the onLoad event fires, invoking the showNameInFrame() function. The showNameInFrame() function replaces the contents of the title frame with an H1 element containing the map name.

The map name isn't available until the map is fully loaded. We got around this problem by redirecting the name to a separate frame after the map loaded. Another approach would be to use dynamic HTML to display the name in the same page as the map. See a third-party dynamic HTML reference for details.

See Also

setName, MapName