Measuring Height
Introducing the process of measuring and outputting elevation and relative altitude within the map. This page discusses the process of changing the mouse mode to height measurement mode in the map and visualizing the measurement results using JSPoint.
Elevation and Ground Altitude
Height is commonly measured as elevation above sea level and ground altitude.

Elevation: Height measured from the sea level.
Ground Altitude: Height measured from the ground surface.
In this sample code, when the ground is clicked, the elevation value is displayed, and when a building or other facility is clicked, both the elevation and ground altitude values are displayed together.

Following are the detailed steps of the process.
Global Variables
Before implementing the functionality, global variables are declared.
Symbol
The texture map object that stores image textures is stored here.
For a brief description of JSSymbol, refer to the explanation of JSSymbol in the step 5. Creating Distance Object section of the distance measurement tutorial.
Layer
The layer where the JSPoint object will be stored is saved in this variable.
The process of saving the layer is described in the step 1. Creating Layer step.
Implementing the Functionality
step 1. Creating Layer
A layer is created to visualize the height measurement icon and height values.
For a description of layer types, see here.
step 2. Registering Events
Events are registered to receive the calculated height from the engine.
The Fire_EventAddAltitudePoint event occurs when the mouse mode is set to MML_ANALYS_ALTITUDE.
The process of setting the mouse mode is described in the next step, step 3. Changing Mouse Mode.
After changing the mouse mode and clicking on the map, the height information is returned as event parameters.

dLon: Longitude of the height measurement location
dLat: Latitude of the height measurement location
dAlt: Altitude of the height measurement location
dGroundAltitude: Elevation value. If the ground is clicked, this value will be the same as dAlt.
dObjectAltitude: Ground altitude value
Based on this event information, the createPOI function creates a JSPoint object to display the altitude information.
The following process describes various canvas drawing functions before creating the JSPoint object.
To directly proceed to the step of creating the JSPoint object, go here.
step 3. Changing Mouse Mode
The mouse mode is changed for height measurement.
For a description of mouse modes, see here.
step 4 - 1. Creating Height Icon
The function below creates an icon to render the received height value.
Executing the function will create the following image on the canvas.

First, a canvas is created to draw the image, then a background for the text is painted (step 4-3. Creating Height Rectangle Icon),
Based on the returned altitude values, text is entered. (step 4-4. Creating Height Measurement Result Icon)
Finally, a location indicator dot is drawn to mark the clicked location. (step 4-2. Creating Height Point Icon)
step 4 - 2. Creating Height Point Icon
A Point Icon is created to visualize the measured height location.
step 4 - 3. Creating Height Rectangle Icon
A rectangle is drawn as a background to visualize the received height value.
step 4 - 4. Creating Height Measurement Result Icon
The received height value is written as text on the rectangle icon.
step 4 - 5. Converting Height Measurement to m/km Text
If necessary, the received height value is converted to m/km text.
step 5. Creating Height Object
An object is created with the created icon and added to the layer.
step 6. Resetting Height Measurement
Height measurement results and objects are reset.
Result Screen
After completing all the steps, you will have a measurement feature that displays height information at the clicked location.

If you want to check the live code for the height measurement process, click here.
Last updated