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

Syntax

double getHeight(String units)

Description

Gets the height of the map.

The height value is returned in the current default units, unless you specify another unit with the units parameter.

Parameters

units - The type of height units to use, either M (meters, the default), KM (kilometers), FT (feet), or MI (miles). The Autodesk MapGuide Viewer Plug-In and the Autodesk MapGuide Viewer, Java Edition also take "" and null. They use the current default units.

Returns

double - The height of the map.

Error Codes

none

Example

The following example is designed to work with the Tutorial.mwf file that is included with Autodesk MapGuide Author. It uses the KM argument to display a dialog box showing the height and width of the map in kilometers:

function showSize()
{
    var map = getMap();
    
    var width = map.getWidth("KM");
    var height = map.getHeight("KM");
    alert("width: " + width + ", height: " + height);
}

Here's a more complex use of getHeight() and getWidth(). In the following example, an HTML form lets the user select the unit of measurement from a drop-down list:

<FORM NAME="myForm">
    <SELECT NAME="optionList" size="1" onChange="showSize();">
        <OPTION VALUE="MI">miles</OPTION>
        <OPTION VALUE="FT">feet</OPTION>
        <OPTION VALUE="KM">kilometers</OPTION>
        <OPTION VALUE="M">meters</OPTION>
    </SELECT>
    <INPUT TYPE="button" VALUE="Go..." ONCLICK="showSize();">
</FORM>

The form calls a JavaScript function, passing it the value and text properties of the selected form option:

function showSize()
{
    var map = getMap();

    // For selected form option, get array index, VALUE
    // attribute, and option name as it appears in the browser
    var idx = window.document.myForm.optionList.selectedIndex;
    var val = window.document.myForm.optionList.options[idx].value;
    var type = window.document.myForm.optionList.options[idx].text;

    // Use val and type to call height/width methods and display alert
    alert( "Size is " + map.getWidth(val) + " by " + map.getHeight(val) + " " + type);
}

If the user selected kilometers from the form, showSize would read the selected item's value and text properties ("KM" and "kilometers", respectively). In that case, the line:

    alert( "Size is " + map.getWidth(val) + " by " + map.getHeight(val) + " " + type);

Would evaluate as:

    alert( "Size is " + map.getWidth("KM") + " by " + map.getHeight("KM") + " " + "kilometers");

See Also

MapHeight