Measuring Radius

Change the mouse mode to radius measurement mode, then measure the radius from the click point.

The first click point becomes the center, and the distance to the second click point forms the radius.

The measurement results are returned via an event and visualized as a POI.

Feature Implementation

Symbol

A texture map object that stores image textures is stored here.

For a brief explanation of JSSymbol, refer to the step 5. Creating a Distance Object section of the distance measurement tutorial.

POILayer

This variable stores the layer where the created JSPoint objects are saved.

The process of storing the layer is referred to in the step 1. Creating a Layer phase.

WallLayer

This is a layer that stores the wall polygon that delineates the radius.

The process of storing the layer is referred to in the step 1. Creating a Layer phase.

chevron-rightHere is the complete code that implements the above feature.hashtag

Following are the detailed steps of the code.

step 1. Creating a Layer

Create a layer to visualize the radius measurement Icon and radius value.

For an explanation of layer types, refer here.

step 2. Registering an Event

Register an event to receive the calculated radius.

The Fire_EventAddRadius event occurs when the mouse mode is set to MML_ANALYS_AREA_CIRCLE.

step 3. Changing Mouse Mode

Change the mouse mode for radius measurement.

For an explanation of mouse modes, refer here.

step 4 - 1. Creating a Radius Icon

Create an Icon to render the returned radius value.

First, create a canvas to draw the image, paint a background for the text (step 4-2. Creating a Radius Balloon Icon), and then input the returned altitude value as text (step 4-3. Creating a Radius Measurement Result Icon).

step 4 - 2. Creating a Radius Balloon Icon

Draw a balloon on the canvas to visualize the returned radius value.

step 4 - 3. Creating a Radius Measurement Result Icon

Draw the returned radius value as text on the balloon.

step 4 - 4. Converting to m/km Text

Convert the returned radius value to m/km text.

step 5. Creating a Radius Object

Create an object with the created Icon and add it to the layer.

step 6. Clearing Radius Measurement

Clear the radius measurement results and objects.

Result Screen

If you want to check the live code of the radius measurement process, click herearrow-up-right.

Last updated